-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππ Big improvements to benchmarks.
π₯ was able to delete some of my earlier custom benchmark code
- Loading branch information
Showing
16 changed files
with
1,104 additions
and
916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
prelude: "val = nil" | ||
teardown: "puts val" # ensure it is used and not somehow optimized away | ||
|
||
benchmark: | ||
|
||
- name: "random_val" | ||
prelude: | | ||
require "d_heap/benchmarks" | ||
include DHeap::Benchmarks | ||
fill_random_vals | ||
script: "random_val" | ||
|
||
- name: "inline random_vals.fetch" | ||
prelude: | | ||
random_idx = -1 | ||
random_len = 1_000_000 | ||
random_vals = Array.new(random_len) { rand(0..10_000) } | ||
script: | | ||
random_idx = ((random_idx + 1) % random_len) | ||
val = random_vals.fetch((random_idx + 1) % random_len) | ||
- name: "inline random_vals[]" | ||
prelude: | | ||
random_idx = -1 | ||
random_len = 1_000_000 | ||
random_vals = Array.new(random_len) { rand(0..10_000) } | ||
script: | | ||
random_idx = ((random_idx + 1) % random_len) | ||
val = random_vals.fetch((random_idx + 1) % random_len) | ||
- name: "rand(range)" | ||
prelude: "range = 0..10_000" | ||
script: "val = rand(range)" | ||
|
||
- name: "rand(0..10_000)" | ||
script: "val = rand(0..10_000)" | ||
|
||
# - name: "just a method call" | ||
# prelude: | | ||
# def random_val; 1 end | ||
# script: | | ||
# val = random_val | ||
# - name: "just increment" | ||
# prelude: | | ||
# i = 0 | ||
# script: | | ||
# i += 1 | ||
# val = i | ||
# - name: "just assign a constant" | ||
# script: "val = 1" | ||
# - name: "noop" | ||
# script: "val" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
set -eu | ||
|
||
export BENCH_N="$1" | ||
shift | ||
bin/rake clean compile > /dev/null 2>&1 | ||
|
||
exec ruby "$@" | ||
ruby -r bundler/setup -r d_heap/benchmarks/benchmarker \ | ||
-e 'DHeap::Benchmarks.puts_version_info("Benchmarking")' | ||
|
||
function join_by { local IFS="$1"; shift; echo "$*"; } | ||
|
||
PUSH_POP_HEAP_SIZES=( | ||
"N 1000000" | ||
"N 10000000" | ||
"N 3162278" | ||
"N 316228" | ||
"N 100000" | ||
"N 31623" | ||
"N 10000" | ||
"N 3162" | ||
"N 1000" | ||
"N 316" | ||
"N 100" | ||
"N 32" | ||
"N 10" | ||
) | ||
|
||
# run-duration is used for the *first* executable and used during warmup to | ||
# determine a loop count that will be identical for all runs. | ||
# | ||
# If we run the largest N first, we expect all later runs to be faster. For | ||
# algorithms with high time complexity, the later runs will be so much faster | ||
# that they may not run enough iterations to get a good measurement. | ||
# | ||
# If we run the slowest N first, we expect all later runs to be slower. For | ||
# algorithms with high time complexity, the later runs will be so much slower | ||
# that they may take hours to complete. | ||
# | ||
# I'm splitting the difference and calculate the loop count from 1/10 of max N. | ||
# | ||
# TODO: create a new benchmark_driver/runner class that targets a different loop | ||
# count for each executable, since they could have wildly divergent ips. | ||
|
||
bin/benchmark-driver --bundle \ | ||
-e "$(join_by ";" "${PUSH_POP_HEAP_SIZES[@]}")" \ | ||
--repeat-count 4 \ | ||
benchmarks/push_pop.yml \ | ||
"$@" |
Oops, something went wrong.