Skip to content

Instantly share code, notes, and snippets.

View ScottPJones's full-sized avatar

Scott P. Jones ScottPJones

  • Gandalf Software, Inc.
  • Beverly, MA USA
View GitHub Profile
@ScottPJones
ScottPJones / gist:d673d7497eb453aa790605ca6d4726bb
Created March 17, 2018 02:24
Comparison of Str types to String, on a variety of different text files in different languages
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 February 15, 2018 22:25
Code generation of ('0' + q)%UInt8
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 February 5, 2018 19:00
Benchmark (fixed) version of `r23` from Discourse, and longer version
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 January 1, 2018 16:49
Performance results on v0.7 latest (1-1-2018)
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
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 December 19, 2017 20:39
Performance data of string/character processing
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 20:59
Testing output of ParameterizedFunctions
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.
module ArbFlts
import Base: +, -, /, *, sqrt, inv
using ArbFloats
export ArbFlt, ArbFlt160
export invsqrt
#=
@ScottPJones
ScottPJones / BigFloats.jl
Created June 29, 2016 03:19
Latest (WIP) version of BigFlt (to replace BigFloat) module, with Flt type
# 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 June 22, 2016 09:46
WIP on BigFloat replacement
# This file is a part of Julia. License is MIT: http://julialang.org/license
module BigFloats
export
FloatRef,
setprecision,
BigFlt, Flt, Flt128, Flt256, Flt512