[latex3-commits] [git/LaTeX3-latex3-latex3] master: Round benchmark times to three significant figures (f8727e8)

Bruno Le Floch bruno at le-floch.fr
Sat Nov 3 22:19:02 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/f8727e87431b8413c7e73c3d6f90f54cc415826f

>---------------------------------------------------------------

commit f8727e87431b8413c7e73c3d6f90f54cc415826f
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sat Nov 3 22:19:02 2018 +0100

    Round benchmark times to three significant figures
    
    In my tests, repeating a benchmark many times gives roughly a 1% to 4% spread
    in the resulting values, so it makes some (limited) sense to keep three
    significant figures.


>---------------------------------------------------------------

f8727e87431b8413c7e73c3d6f90f54cc415826f
 l3experimental/l3benchmark/l3benchmark.dtx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/l3experimental/l3benchmark/l3benchmark.dtx b/l3experimental/l3benchmark/l3benchmark.dtx
index 8f3fc91..c29825b 100644
--- a/l3experimental/l3benchmark/l3benchmark.dtx
+++ b/l3experimental/l3benchmark/l3benchmark.dtx
@@ -243,9 +243,15 @@
 %   number of operations.  This can be redefined by the user.
 %    \begin{macrocode}
 \cs_new_protected:Npn \benchmark_display:
-  { \iow_term:x { \fp_to_tl:N \g_benchmark_time_fp \c_space_tl seconds } }
+  {
+    \fp_gset:Nn \g_benchmark_time_fp
+      { round(\g_benchmark_time_fp, 2 - logb(\g_benchmark_time_fp)) }
+    \iow_term:x { \fp_to_tl:N \g_benchmark_time_fp \c_space_tl seconds }
+  }
 \cs_new_protected:Npn \benchmark_display_in_ops:
   {
+    \fp_gset:Nn \g_benchmark_ops_fp
+      { round(\g_benchmark_ops_fp, 2 - logb(\g_benchmark_ops_fp)) }
     \iow_term:x
       {
         \fp_compare:nTF { \g_benchmark_ops_fp > 1e9 }





More information about the latex3-commits mailing list