Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott P. Jones ScottPJones

  • Gandalf Software, Inc.
  • Beverly, MA USA
View GitHub Profile
@ScottPJones
ScottPJones / gist:d673d7497eb453aa790605ca6d4726bb
Created Mar 17, 2018
Comparison of Str types to String, on a variety of different text files in different languages
View gist:d673d7497eb453aa790605ca6d4726bb
File name Lines Chars Avg C/L Empty Min Max MaxType
ASCII-Dict.txt 235886 2257223 9.569 0 1 24 ASCIIStr
Character Types: ASCII Latin1 2-Byte UCS2 UTF32 Surrogate Invalid
Total characters: 2257223 0 0 0 0 0 0
Lines with > 0: 235886 0 0 0 0 0 0
File name Lines Chars Avg C/L Empty Min Max MaxType
ASCII-Dict.txt 1000 9500 9.500 0 7 12 ASCIIStr
Character Types: ASCII Latin1 2-Byte UCS2 UTF32 Surrogate Invalid
@ScottPJones
ScottPJones / gist:8531146104d22a3a46b6777e90968b42
Last active Feb 15, 2018
Code generation of ('0' + q)%UInt8
View gist:8531146104d22a3a46b6777e90968b42
julia> f(q) = ('0' + q)%UInt8
f (generic function with 1 method)
julia> @code_native f(0x9)
.section __TEXT,__text,regular,pure_instructions
; Function f {
; Location: REPL[9]:1
pushq %rbp
pushq %r14
pushq %rbx
@ScottPJones
ScottPJones / r23.jl
Created Feb 5, 2018
Benchmark (fixed) version of `r23` from Discourse, and longer version
View r23.jl
using BenchmarkTools
function r23(obs, mod)
bis = (!isnan).(obs) .& (!isnan).(mod); # == !isnan.(obs.*mod)
dobs = obs[bis] .- mean(obs[bis])
dmod = mod[bis] .- mean(mod[bis])
sum((dobs .* dmod)) / sqrt( sum((dobs .^ 2)) * sum((dmod .^ 2)) )
end
function spj(obs, mod)
@ScottPJones
ScottPJones / bench-2018-01-01.txt
Created Jan 1, 2018
Performance results on v0.7 latest (1-1-2018)
View bench-2018-01-01.txt
julia> dispbench(res)
File name Lines Chars Avg C/L Empty Min Max MaxType
ASCII-Dict.txt 235886 2257223 9.569 0 1 24 ASCIIStr
Character Types: ASCII Latin1 2-Byte UCS2 UTF32 Surrogate Invalid
Total characters: 2257223 0 0 0 0 0 0
Lines with > 0: 235886 0 0 0 0 0 0
Type B/Char sizeof length isascii isvalid
string string
View Comparison of code generated for `@printf` vs `pr"..."`
julia> prx(nam,i,f,r) = pr"\%-5d(i), 0x\%x(i), \%(i), <\%-10s(nam)>, <\%10s(nam)>, \%7.3f(f), \%(r)\n"
prx (generic function with 1 method)
julia> @code_warntype prx("scott", 42, pi, 1//200)
Variables:
#self# <optimized out>
nam::String
i::Int64
f::Irrational{:π}
r::Rational{Int64}
@ScottPJones
ScottPJones / output-v0.7-post24999.txt
Created Dec 19, 2017
Performance data of string/character processing
View output-v0.7-post24999.txt
14:29 $ julia7
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0-DEV.3108 (2017-12-19 11:51 UTC)
_/ |\__'_|_|_|\__'_| | Commit c16c0cb* (0 days old master)
|__/ | x86_64-apple-darwin17.3.0
@ScottPJones
ScottPJones / gist:9cfda9c15a81ab5d5715408b0a067e49
Created May 8, 2017
Testing output of ParameterizedFunctions
View gist:9cfda9c15a81ab5d5715408b0a067e49
julia> include("/Users/scott/.julia/v0.6/ParameterizedFunctions/test/runtests.jl")
INFO: Recompiling stale cache file /Users/scott/.julia/lib/v0.6/DataStructures.ji for module DataStructures.
INFO: Precompiling module DiffEqBase.
WARNING: deprecated syntax "abstract $def" at /Users/scott/.julia/v0.6/Media/src/system.jl:42.
Use "abstract type $def end" instead.
WARNING: deprecated syntax "typealias $Symbol(string(T,"T")){T<:$T} Type{T}" at /Users/scott/.julia/v0.6/Media/src/system.jl:43.
Use "$Symbol(string(T,"T")){T<:$T} = Type{T}" instead.
View packedarbs.jl
module ArbFlts
import Base: +, -, /, *, sqrt, inv
using ArbFloats
export ArbFlt, ArbFlt160
export invsqrt
#=
@ScottPJones
ScottPJones / BigFloats.jl
Created Jun 29, 2016
Latest (WIP) version of BigFlt (to replace BigFloat) module, with Flt type
View BigFloats.jl
# This file is a part of Julia. License is MIT: http://julialang.org/license
module BigFloats
export
FloatRef,
setprecision,
BigFlt, Flt, Flt128, Flt256, Flt512
@ScottPJones
ScottPJones / BigFloats.jl
Created Jun 22, 2016
WIP on BigFloat replacement
View BigFloats.jl
# This file is a part of Julia. License is MIT: http://julialang.org/license
module BigFloats
export
FloatRef,
setprecision,
BigFlt, Flt, Flt128, Flt256, Flt512
You can’t perform that action at this time.