[latex3-commits] [git/LaTeX3-latex3-latex3] master: Benchmark for minimum not median time (f968232)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Oct 25 13:27:58 CEST 2018


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

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

commit f96823253981ffc778b13b0d1389fe7560963c5e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Oct 25 12:27:58 2018 +0100

    Benchmark for minimum not median time


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

f96823253981ffc778b13b0d1389fe7560963c5e
 l3experimental/l3benchmark/l3benchmark.dtx         |   45 ++++++++------------
 .../l3benchmark/testfiles/m3benchmark000.tlg       |    1 -
 2 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/l3experimental/l3benchmark/l3benchmark.dtx b/l3experimental/l3benchmark/l3benchmark.dtx
index 4dc129a..c0dbc7d 100644
--- a/l3experimental/l3benchmark/l3benchmark.dtx
+++ b/l3experimental/l3benchmark/l3benchmark.dtx
@@ -368,7 +368,7 @@ end
 %    \end{macrocode}
 % \end{variable}
 % 
-% \begin{variable}{\g_@@_time_int, \g_@@_time_a_int, \g_@@_time_b_int, \g_@@_time_c_int, \g_@@_time_d_int, \g_@@_time_median_int}
+% \begin{variable}{\g_@@_time_int, \g_@@_time_a_int, \g_@@_time_b_int, \g_@@_time_c_int, \g_@@_time_d_int}
 %   These variables hold the time for running a piece of code, as an
 %   integer in scaled seconds.
 %    \begin{macrocode}
@@ -377,7 +377,6 @@ end
 \int_new:N \g_@@_time_b_int
 \int_new:N \g_@@_time_c_int
 \int_new:N \g_@@_time_d_int
-\int_new:N \g_@@_time_median_int
 %    \end{macrocode}
 % \end{variable}
 %
@@ -470,25 +469,6 @@ end
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_set_median:, \@@_set_median:NNNN}
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_set_median:
-  {
-    \@@_set_median:NNNN \g_@@_time_a_int \g_@@_time_b_int
-      \g_@@_time_c_int \g_@@_time_d_int
-  }
-\cs_new_protected:Npn \@@_set_median:NNNN #1#2#3#4
-  {
-    \int_gset:Nn \g_@@_time_median_int
-      {
-        ( #1 + #2 + #3 + #4
-        - \int_min:nn { \int_min:nn #1 #2 } { \int_min:nn #3 #4 }
-        - \int_max:nn { \int_max:nn #1 #2 } { \int_max:nn #3 #4 } ) / 2
-      }
-  }
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\benchmark:n, \benchmark_silent:n}
 %   The main timing function. First time the user code once.  If that
 %   took more than a third of a second we're done.  If that took much
@@ -497,9 +477,8 @@ end
 %   zero time).  Once we reach a reasonable time, compute a number of
 %   times that can fit in one quarter of a second and measure that four
 %   times.  To save time we reuse the result of the first pass if
-%   \cs{g_@@_repeat_int} is one.  Once we have four results, take their
-%   median and display that, divided by $65536$ and by the number of
-%   repetitions.
+%   \cs{g_@@_repeat_int} is one.  Once we have four results, find the smallest,
+%   divided by $65536$ and by the number of repetitions, and display that.
 %    \begin{macrocode}
 \fp_new:N \g_@@_one_op_fp
 \tl_new:N \g_@@_code_tl
@@ -531,14 +510,20 @@ end
     \@@_raw:nN { \g_@@_code_tl } \g_@@_time_int
     \int_compare:nNnF \g_@@_time_int < { \g_@@_duration_int / 2 }
       {
-        \int_gset_eq:NN \g_@@_time_median_int \g_@@_time_int
+        \int_gset_eq:NN \g_@@_time_a_int \g_@@_time_int
+        \int_gset_eq:NN \g_@@_time_b_int \g_@@_time_int
+        \int_gset_eq:NN \g_@@_time_c_int \g_@@_time_int
+        \int_gset_eq:NN \g_@@_time_d_int \g_@@_time_int
         \prg_break:
       }
     \int_while_do:nNnn \g_@@_time_int < { \g_@@_duration_int / 100 }
       {
         \int_compare:nNnT \g_@@_repeat_int > { \c_max_int / 4 }
           {
-            \int_gset:Nn \g_@@_time_median_int { 0 }
+            \int_gzero:N \g_@@_time_a_int
+            \int_gzero:N \g_@@_time_b_int
+            \int_gzero:N \g_@@_time_c_int
+            \int_gzero:N \g_@@_time_d_int
             \prg_break:
           }
         \int_gset:Nn \g_@@_repeat_int { 4 * \g_@@_repeat_int }
@@ -558,10 +543,14 @@ end
     \@@_run:N \g_@@_time_b_int
     \@@_run:N \g_@@_time_c_int
     \@@_run:N \g_@@_time_d_int
-    \@@_set_median:
     \prg_break_point:
     \fp_gset:Nn \g_benchmark_time_fp
-      { \g_@@_time_median_int / \g_@@_repeat_int / 65536 }
+      {
+        \int_min:nn
+          { \int_min:nn \g_@@_time_a_int \g_@@_time_b_int }
+          { \int_min:nn \g_@@_time_c_int \g_@@_time_d_int }
+          / \g_@@_repeat_int / 65536
+      }
   }
 \cs_new_protected:Npn \@@_run:N
   { \exp_args:NNo \@@_raw_replicate:nnN \g_@@_repeat_int { \g_@@_code_tl } }
diff --git a/l3experimental/l3benchmark/testfiles/m3benchmark000.tlg b/l3experimental/l3benchmark/testfiles/m3benchmark000.tlg
index 49f6cac..c561501 100644
--- a/l3experimental/l3benchmark/testfiles/m3benchmark000.tlg
+++ b/l3experimental/l3benchmark/testfiles/m3benchmark000.tlg
@@ -8,7 +8,6 @@ Package: l3benchmark ....-..-.. L3 Experimental benchmarking
 \g__benchmark_time_b_int=\count...
 \g__benchmark_time_c_int=\count...
 \g__benchmark_time_d_int=\count...
-\g__benchmark_time_median_int=\count...
 \g__benchmark_repeat_int=\count...
 \g__benchmark_nesting_int=\count...
 \g__benchmark_tictoc_int=\count...





More information about the latex3-commits mailing list