lilydjwg / swapview-rosetta

Print swap usage per process. Implemented in various programming languages
491 stars 108 forks source link

Racket*:use `filter-map` #183

Closed Antigen-1 closed 1 year ago

Antigen-1 commented 2 years ago

Avoid building the intermediate list.

Antigen-1 commented 2 years ago
---------Results--------(Diff):  KMinAvg      Min      Avg      Max    Stdev  Cnt
C++98_omp               (100%):   122.67    91.85   165.06   249.06    49.55   20
Python3_mp              (100%):   129.55   126.64   133.99   148.15     5.80   20
Perl_parallel           (100%):   149.99   139.08   159.26   188.84    12.08   20
C                       (100%):   226.60   225.65   235.99   266.48    12.20   20
C++17                   (100%):   250.78   245.57   259.77   289.74    11.94   20
C++98                   (100%):   253.36   243.69   264.88   303.93    15.54   20
C++14                   (100%):   274.97   247.43   289.88   318.10    20.84   20
C++11                   ( 91%):   292.06   281.73   305.70   352.84    18.76   20
Python3                 (100%):   307.46   294.74   318.53   353.81    15.58   20
Python3_bytes           (100%):   451.67   432.32   465.72   511.27    18.68   20
Perl                    (100%):   489.80   477.19   504.51   528.39    16.27   20
ChezScheme              (100%):   589.48   574.64   602.43   631.11    16.47   20
Racket_parallel         (100%):   600.13   585.40   615.93   661.65    20.08   20
Racket_compiled         (100%):   800.14   796.38   804.47   823.18     6.15   20
Racket                  (100%):   804.91   802.47   816.74   848.46    16.07   20
POSIX_dash              ( 95%):   967.83   955.56   974.41   993.36     8.68   20
POSIX_bash              ( 95%):  1175.02  1079.52  1271.85  1488.41   119.68   20
Bash_parallel           ( 12%):  1268.55  1252.86  1299.80  1498.26    55.47   20
Tcl                     ( 95%):  1331.60  1303.81  1344.26  1383.34    18.02   20
Bash                    ( 87%):  1426.80  1403.58  1473.91  1718.02    74.65   20
------------Fails-------------------
Antigen-1 commented 2 years ago

More changes are submitted to avoid building unnecessary lists in the process of outputting.

Antigen-1 commented 2 years ago

I plan to add a Typed_racket version, which is written in typed racket, a sister language of racket with a static type-checker. The performance, though, is even worse than the Racket_compiled version. The reason appears to lie in the absence of standard libraries, with typed/racket providing all bindings I need. Could you please give it a shot?