Skip to content

Instantly share code, notes, and snippets.

View PragTob's full-sized avatar

Tobias Pfeiffer PragTob

View GitHub Profile
@PragTob
PragTob / bench.exs
Created March 8, 2022 15:47
Benchee reduction counting example
list = Enum.to_list(1..10_000)
map_fun = fn i -> [i, i * i] end
Benchee.run(
%{
"flat_map" => fn -> Enum.flat_map(list, map_fun) end,
"map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten() end
},
reduction_time: 2
)
tobi@speedy:~$ uname -a
Linux speedy 5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
tobi@speedy:~$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
@PragTob
PragTob / rubykon_deoptimize.txt
Created August 11, 2020 18:09
Rubykon Graal deoptimizations
tobi@speedy:~/github/rubykon(main)$ ruby --jvm -v
truffleruby 20.1.0, like ruby 2.6.5, GraalVM CE JVM [x86_64-linux]
tobi@speedy:~/github/rubykon(main)$ ruby --jvm --experimental-options --engine.TraceTransferToInterpreter --engine.BackgroundCompilation=false benchmark/mcts_avg.rb
Running your benchmark...
--------------------------------------------------------------------------------
[engine] transferToInterpreter at
Array#[]((core):1) <split-133c56f7>
Rubykon::Board#neighbours_of(lib/rubykon/board.rb:50)
Rubykon::MoveValidator#no_suicide_move?(lib/rubykon/move_validator.rb:38)
Rubykon::MoveValidator#trusted_valid?(lib/rubykon/move_validator.rb:18)
Operating System: Linux
CPU Information: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Number of Available Cores: 8
Available memory: 15.61 GB
Elixir 1.9.1
Erlang 22.0
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
@PragTob
PragTob / bench_result.txt
Created September 19, 2019 13:57
spigot_bench_result
Operating System: Linux
CPU Information: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Number of Available Cores: 8
Available memory: 15.61 GB
Elixir 1.9.0
Erlang 22.0
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
@PragTob
PragTob / jruby
Created July 14, 2019 09:00
Jruby run
Using Java adoptopenjdk-8.212
Running jruby-9.1.17.0
jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 OpenJDK 64-Bit Server VM 25.212-b03 on 1.8.0_212-b03 +jit [linux-x86_64]
Running your benchmark...
--------------------------------------------------------------------------------
Finished warm up for 19x19 1_000 iterations, running the real bechmarks now
Finished measuring the run time for 19x19 1_000 iterations
Benchmarking finished, here are your reports...
Warm up results:
@PragTob
PragTob / reuse.ex
Created July 5, 2019 16:11
statistex reuse example
iex> Statistex.variance([4, 9, 11, 12, 17, 5, 8, 12, 12], sample_size: 9, average: 10.0)
16.0
@PragTob
PragTob / statistex.exs
Last active July 5, 2019 16:02
Statistex statistis/2
iex> samples = [1, 3.0, 2.35, 11.0, 1.37, 35, 5.5, 10, 0, 2.35]
iex> Statistex.statistics(samples)
%Statistex{
average: 7.156999999999999,
frequency_distribution: %{
0 => 1,
1 => 1,
10 => 1,
35 => 1,
1.37 => 1,
check all samples <- list_of(float(), min_length: 1) do
percies = percentiles(samples, [25, 50, 75, 90, 99])
assert percies[25] <= percies[50]
assert percies[50] <= percies[75]
assert percies[75] <= percies[90]
assert percies[90] <= percies[99]
end
@PragTob
PragTob / statistex_test.exs
Created June 24, 2019 16:19
statistex property
check all samples <- list_of(float(), min_length: 1) do
stats = statistics(samples)
assert stats.sample_size >= 1
assert stats.minimum <= stats.maximum
assert stats.minimum <= stats.average
assert stats.average <= stats.maximum
assert stats.minimum <= stats.median