Skip to content

Instantly share code, notes, and snippets.

View PragTob's full-sized avatar

Tobias Pfeiffer PragTob

View GitHub Profile
@PragTob
PragTob / mix.lock
Created January 23, 2017 15:19
Mix.lock that produces seemingly updataable phoenix_live_reload
%{"appsignal": {:hex, :appsignal, "0.11.2", "5f1866e135db317926580b2c234717c059a2d337b28530c847279d76d4acbb43", [:make, :mix], [{:decorator, "~> 1.0", [hex: :decorator, optional: false]}, {:phoenix, "~> 1.2.0", [hex: :phoenix, optional: true]}, {:poison, "~> 2.1", [hex: :poison, optional: false]}]},
"base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], []},
"basic_auth": {:hex, :basic_auth, "1.0.0", "fc16c423023f4e855d9be3e8a5faa5ca5affc34efff72f75a293362566fc696f", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: false]}, {:plug, "~> 0.14 or ~> 1.0", [hex: :plug, optional: false]}]},
"bbmustache": {:hex, :bbmustache, "1.0.4", "7ba94f971c5afd7b6617918a4bb74705e36cab36eb84b19b6a1b7ee06427aa38", [:rebar], []},
"bugsnex": {:hex, :bugsnex, "0.0.1", "ac21bc853d6d0fb9fd559f0905f083b67e2440bbcd2e32c3b77f83fb7faebadc", [:mix], [{:httpoison, "~> 0.8.3", [hex: :httpoison, optional: false]}, {:plug, "~> 1.1", [hex: :plug, optional: false]}, {:
tobi@speedy ~/github/rubykon $ benchmark/benchmark.sh benchmark/mcts_avg.rb
Running 2.0.0
Using /home/tobi/.rvm/gems/ruby-2.0.0-p648
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
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...
tobi@speedy ~/github/rubykon $ ./benchmark/benchmark.sh benchmark/full_playout.rb && ./benchmark/benchmark.sh benchmark/mcts_avg.rb
Running rbx-2.5.8
Using /home/tobi/.rvm/gems/rbx-2.5.8
rubinius 2.5.8 (2.1.0 bef51ae3 2015-07-14 3.5.2 JI) [x86_64-linux-gnu]
Warming up --------------------------------------
19x19 full playout (+ score)
8.000 i/100ms
Calculating -------------------------------------
19x19 full playout (+ score)
85.969 (± 3.5%) i/s - 2.576k
This file has been truncated, but you can view the full file.
tobi@speedy ~/github/rubykon $ ../jruby/bin/jruby-truffle-tool --graal-path ~/dev/graalvm-0.18-re/bin/java run --graal --no-asserts -- benchmark/mcts_avg.rb
jtt: detected gem/app: rubykon
jtt: executing "run" command
jtt: $ JAVACMD="/home/tobi/dev/graalvm-0.18-re/bin/java" /home/tobi/github/jruby/tool/jt.rb ruby -X\+T -J-Xmx2G -Xtruffle.core.load_path\=/home/tobi/github/jruby/truffle/src/main/ruby -r /home/tobi/github/rubykon/.jruby-truffle-tool_bundle/bundler/setup.rb -I /home/tobi/github/jruby/lib/ruby/truffle/jruby-truffle-tool/lib benchmark/mcts_avg.rb
$ /home/tobi/github/jruby/bin/jruby -X+T -Xtruffle.core.load_path=/home/tobi/github/jruby/truffle/src/main/ruby -Xtruffle.graal.warn_unless=false -X+T -J-Xmx2G -Xtruffle.core.load_path=/home/tobi/github/jruby/truffle/src/main/ruby -r /home/tobi/github/rubykon/.jruby-truffle-tool_bundle/bundler/setup.rb -I /home/tobi/github/jruby/lib/ruby/truffle/jruby-truffle-tool/lib benchmark/mcts_avg.rb
Running your benchmark...
------------------------------------------
@PragTob
PragTob / benchmark_result
Created November 1, 2016 08:24
TCO vs. non TCO with 10_000_000 elements
tobi@happy ~/github/elixir_playground $ mix run bench/my_map_bench.exs
Erlang/OTP 19 [erts-8.1] [source-4cc2ce3] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.3.4
Benchmark suite executing with the following configuration:
warmup: 10.0s
time: 30.0s
parallel: 1
Estimated total run time: 360.0s
Benchmarking exactly_like_my_map...
defmodule MyMap do
def map_tco(list, function) do
Enum.reverse _map_tco([], list, function)
end
defp _map_tco(acc, [head | tail], function) do
_map_tco([function.(head) | acc], tail, function)
end
defp _map_tco(acc, [], _function) do
@PragTob
PragTob / benchmark.rb
Created June 6, 2016 17:49
Ruby flat_map vs. map.flatten
require 'benchmark/ips'
Benchmark.ips do |bm|
list = (0..10_000).to_a
bm.report "flat_map" do
list.flat_map do |x|
[x, x * x]
end
end
@PragTob
PragTob / instance_variabe_get.rb
Created October 23, 2015 15:47
instance_variable_get performance
require 'benchmark/ips'
class Test
def intitialize
@ivar = 'test'
end
def direct
@ivar
end
@PragTob
PragTob / more_meta.rb
Created July 20, 2015 19:15
meta definitions with more work
require 'benchmark/ips'
class Try
def initialize(array)
@array = array
end
define_method :meta_concat_sort do |array|
value = instance_variable_get '@' + :array.to_s