Merge pull request #649 from psychon/make-benchmark-less-exact

Make benchmarks less exact
This commit is contained in:
Daniel Hahler 2016-02-11 21:26:32 +01:00
commit 33b2277df9
1 changed files with 5 additions and 2 deletions

View File

@ -5,7 +5,10 @@ local awful = require("awful")
local GLib = require("lgi").GLib local GLib = require("lgi").GLib
local create_wibox = require("_wibox_helper").create_wibox local create_wibox = require("_wibox_helper").create_wibox
local not_under_travis = not os.getenv("CI") local BENCHMARK_EXACT = os.getenv("BENCHMARK_EXACT")
if not BENCHMARK_EXACT then
print("Doing quick and inexact measurements. Set BENCHMARK_EXACT=1 as an environment variable when you actually want to look at the results.")
end
local measure, benchmark local measure, benchmark
do do
@ -26,7 +29,7 @@ do
local time_per_iter, time_total = measure(f, iters) local time_per_iter, time_total = measure(f, iters)
-- To improve precision, we want to loop for this long -- To improve precision, we want to loop for this long
local target_time = 1 local target_time = 1
while time_total < target_time and not_under_travis do while time_total < target_time and BENCHMARK_EXACT do
iters = math.ceil(target_time / time_per_iter) iters = math.ceil(target_time / time_per_iter)
time_per_iter, time_total = measure(f, iters) time_per_iter, time_total = measure(f, iters)
end end