Skip to content

Conversation

@1RyanK
Copy link
Collaborator

@1RyanK 1RyanK commented Dec 18, 2025

Created the benchmark. I found the results (local machine, single locale) interesting:

-------------------------------------------------------------------------------------- benchmark 'AK_binop_ops': 48 tests --------------------------------------------------------------------------------------
Name (time in ms)                       Min                   Max                  Mean              StdDev                Median                 IQR            Outliers      OPS            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bench_binop_ops[*-1-uint64]         26.0857 (1.02)        35.6457 (1.0)         29.7905 (1.0)        2.8214 (1.28)        29.5923 (1.01)       3.8820 (1.18)          2;0  33.5678 (1.0)          10           1
bench_binop_ops[&-1-uint64]         26.2317 (1.02)        38.7058 (1.09)        30.7992 (1.03)       4.1885 (1.90)        29.2134 (1.0)        7.3744 (2.25)          3;0  32.4684 (0.97)         10           1
bench_binop_ops[/-1-uint64]         25.6010 (1.0)         37.3170 (1.05)        31.6310 (1.06)       3.3666 (1.53)        31.9481 (1.09)       5.2536 (1.60)          2;0  31.6145 (0.94)         10           1
bench_binop_ops[--1-uint64]         27.5107 (1.07)        44.9407 (1.26)        32.4966 (1.09)       5.6902 (2.58)        30.9469 (1.06)       5.0057 (1.53)          2;1  30.7725 (0.92)         10           1
bench_binop_ops[|-1-uint64]         28.4903 (1.11)        44.5689 (1.25)        32.8686 (1.10)       4.5155 (2.05)        31.7958 (1.09)       3.5145 (1.07)          1;1  30.4242 (0.91)         10           1
bench_binop_ops[^-1-uint64]         27.0782 (1.06)        39.2192 (1.10)        32.8978 (1.10)       4.0572 (1.84)        32.1762 (1.10)       5.4591 (1.66)          4;0  30.3972 (0.91)         10           1
bench_binop_ops[+-1-uint64]         30.9288 (1.21)        36.6708 (1.03)        33.6136 (1.13)       2.2047 (1.0)         32.7894 (1.12)       3.5839 (1.09)          4;0  29.7499 (0.89)         10           1
bench_binop_ops[//-1-uint64]        34.8926 (1.36)        44.8963 (1.26)        38.9994 (1.31)       3.6340 (1.65)        38.4870 (1.32)       5.9083 (1.80)          3;0  25.6414 (0.76)         10           1
bench_binop_ops[/-1-bigint]         50.9802 (1.99)        58.2374 (1.63)        54.1831 (1.82)       2.4090 (1.09)        53.5534 (1.83)       3.4914 (1.06)          4;0  18.4559 (0.55)         10           1
bench_binop_ops[&-2-uint64]        207.8411 (8.12)       217.6612 (6.11)       212.5854 (7.14)       3.1771 (1.44)       213.2398 (7.30)       5.2628 (1.60)          3;0   4.7040 (0.14)         10           1
bench_binop_ops[*-2-uint64]        208.8392 (8.16)       220.1548 (6.18)       213.1783 (7.16)       4.0438 (1.83)       212.6316 (7.28)       6.4024 (1.95)          4;0   4.6909 (0.14)         10           1
bench_binop_ops[^-2-uint64]        208.0038 (8.12)       221.2722 (6.21)       213.1857 (7.16)       4.7752 (2.17)       211.1903 (7.23)       6.0265 (1.84)          3;0   4.6907 (0.14)         10           1
bench_binop_ops[--2-uint64]        204.9481 (8.01)       224.0202 (6.28)       213.3460 (7.16)       6.6651 (3.02)       212.8325 (7.29)      10.5074 (3.20)          4;0   4.6872 (0.14)         10           1
bench_binop_ops[|-2-uint64]        208.3945 (8.14)       222.9152 (6.25)       213.5495 (7.17)       4.5865 (2.08)       212.5485 (7.28)       5.6930 (1.73)          4;0   4.6828 (0.14)         10           1
bench_binop_ops[+-2-uint64]        207.9060 (8.12)       223.8045 (6.28)       213.5980 (7.17)       5.1929 (2.36)       212.2536 (7.27)       7.3422 (2.24)          4;0   4.6817 (0.14)         10           1
bench_binop_ops[//-2-uint64]       221.2168 (8.64)       238.3268 (6.69)       227.0124 (7.62)       5.5931 (2.54)       224.6553 (7.69)       9.3676 (2.85)          3;0   4.4050 (0.13)         10           1
bench_binop_ops[/-2-uint64]        233.1114 (9.11)       245.8307 (6.90)       237.8838 (7.99)       3.8077 (1.73)       237.2269 (8.12)       4.9200 (1.50)          2;0   4.2037 (0.13)         10           1
bench_binop_ops[/-2-bigint]        254.7832 (9.95)       270.9705 (7.60)       260.7886 (8.75)       5.3370 (2.42)       259.7405 (8.89)       4.2229 (1.29)          3;2   3.8345 (0.11)         10           1
bench_binop_ops[|-3-uint64]        295.1071 (11.53)      307.8247 (8.64)       302.9292 (10.17)      4.2692 (1.94)       304.4490 (10.42)      6.5378 (1.99)          3;0   3.3011 (0.10)         10           1
bench_binop_ops[--3-uint64]        298.7936 (11.67)      312.3869 (8.76)       305.2277 (10.25)      4.9428 (2.24)       306.4790 (10.49)      7.8276 (2.38)          5;0   3.2762 (0.10)         10           1
bench_binop_ops[^-3-uint64]        299.0556 (11.68)      331.4766 (9.30)       306.7002 (10.30)      9.6144 (4.36)       306.3648 (10.49)      8.8386 (2.69)          1;1   3.2605 (0.10)         10           1
bench_binop_ops[&-3-uint64]        301.3886 (11.77)      316.6440 (8.88)       309.7045 (10.40)      3.9020 (1.77)       310.4099 (10.63)      3.2821 (1.0)           2;2   3.2289 (0.10)         10           1
bench_binop_ops[+-3-uint64]        303.7218 (11.86)      327.2317 (9.18)       312.2283 (10.48)      7.4940 (3.40)       311.7917 (10.67)      8.0547 (2.45)          4;1   3.2028 (0.10)         10           1
bench_binop_ops[*-3-uint64]        304.4509 (11.89)      338.0890 (9.48)       317.8542 (10.67)     13.0044 (5.90)       315.2275 (10.79)     25.2676 (7.70)          4;0   3.1461 (0.09)         10           1
bench_binop_ops[//-3-uint64]       313.4704 (12.24)      334.9719 (9.40)       319.5398 (10.73)      6.8157 (3.09)       318.5075 (10.90)      8.8628 (2.70)          1;0   3.1295 (0.09)         10           1
bench_binop_ops[/-3-uint64]        324.3689 (12.67)      351.5051 (9.86)       335.3049 (11.26)     10.7726 (4.89)       330.3704 (11.31)     18.5365 (5.65)          3;0   2.9824 (0.09)         10           1
bench_binop_ops[/-3-bigint]        340.8105 (13.31)      382.6044 (10.73)      355.7279 (11.94)     11.7649 (5.34)       351.9160 (12.05)     10.4742 (3.19)          2;1   2.8111 (0.08)         10           1
bench_binop_ops[&-1-bigint]        550.4264 (21.50)      576.9432 (16.19)      559.7875 (18.79)      7.1865 (3.26)       559.2727 (19.14)      5.2330 (1.59)          3;1   1.7864 (0.05)         10           1
bench_binop_ops[|-1-bigint]        550.4004 (21.50)      573.1072 (16.08)      563.0769 (18.90)      6.9726 (3.16)       563.7959 (19.30)      5.1213 (1.56)          4;3   1.7760 (0.05)         10           1
bench_binop_ops[^-1-bigint]        551.9393 (21.56)      651.1150 (18.27)      576.9794 (19.37)     32.2803 (14.64)      564.2084 (19.31)     34.1960 (10.42)         2;1   1.7332 (0.05)         10           1
bench_binop_ops[&-2-bigint]        701.7432 (27.41)      747.5932 (20.97)      721.4190 (24.22)     13.0502 (5.92)       721.7032 (24.70)     13.4274 (4.09)          2;1   1.3862 (0.04)         10           1
bench_binop_ops[*-1-bigint]        700.6477 (27.37)      762.3315 (21.39)      724.5776 (24.32)     19.9615 (9.05)       718.9098 (24.61)     31.0554 (9.46)          3;0   1.3801 (0.04)         10           1
bench_binop_ops[^-2-bigint]        705.8640 (27.57)      764.6509 (21.45)      728.9256 (24.47)     17.5762 (7.97)       724.5973 (24.80)     26.6996 (8.13)          2;0   1.3719 (0.04)         10           1
bench_binop_ops[+-1-bigint]        710.7791 (27.76)      775.0145 (21.74)      732.5447 (24.59)     22.6474 (10.27)      726.5365 (24.87)     38.5758 (11.75)         2;0   1.3651 (0.04)         10           1
bench_binop_ops[--1-bigint]        717.7340 (28.04)      788.9333 (22.13)      742.5055 (24.92)     24.3344 (11.04)      736.4865 (25.21)     23.6355 (7.20)          4;1   1.3468 (0.04)         10           1
bench_binop_ops[|-2-bigint]        702.5954 (27.44)      855.6796 (24.01)      747.7006 (25.10)     45.9158 (20.83)      730.6241 (25.01)      8.9913 (2.74)          2;3   1.3374 (0.04)         10           1
bench_binop_ops[//-1-bigint]       762.7270 (29.79)      803.8537 (22.55)      774.7297 (26.01)     12.7737 (5.79)       769.1248 (26.33)     16.4584 (5.01)          1;0   1.2908 (0.04)         10           1
bench_binop_ops[^-3-bigint]        795.0216 (31.05)      860.8289 (24.15)      822.7201 (27.62)     20.4523 (9.28)       824.1971 (28.21)     23.1235 (7.05)          4;0   1.2155 (0.04)         10           1
bench_binop_ops[|-3-bigint]        808.9377 (31.60)      840.5138 (23.58)      826.1274 (27.73)      9.6186 (4.36)       825.9925 (28.27)      7.4764 (2.28)          4;1   1.2105 (0.04)         10           1
bench_binop_ops[*-2-bigint]        850.5787 (33.22)      881.1129 (24.72)      868.8991 (29.17)      9.3880 (4.26)       869.7632 (29.77)     10.5862 (3.23)          4;0   1.1509 (0.03)         10           1
bench_binop_ops[+-2-bigint]        903.9794 (35.31)      970.4130 (27.22)      927.2220 (31.12)     19.4817 (8.84)       919.9166 (31.49)     22.6919 (6.91)          2;0   1.0785 (0.03)         10           1
bench_binop_ops[&-3-bigint]        804.3750 (31.42)    1,245.4633 (34.94)      935.3478 (31.40)    157.6907 (71.53)      830.1741 (28.42)    247.7263 (75.48)         1;0   1.0691 (0.03)         10           1
bench_binop_ops[//-2-bigint]       926.0527 (36.17)      976.9980 (27.41)      946.9680 (31.79)     15.5689 (7.06)       943.5094 (32.30)     16.6559 (5.07)          3;0   1.0560 (0.03)         10           1
bench_binop_ops[--2-bigint]        892.7496 (34.87)    1,180.4162 (33.12)      957.7997 (32.15)    115.3817 (52.33)      900.5479 (30.83)     48.0250 (14.63)         2;2   1.0441 (0.03)         10           1
bench_binop_ops[*-3-bigint]        956.0638 (37.34)    1,000.7192 (28.07)      974.9023 (32.73)     13.9835 (6.34)       974.4149 (33.36)     20.0853 (6.12)          4;0   1.0257 (0.03)         10           1
bench_binop_ops[--3-bigint]        972.9460 (38.00)    1,057.5071 (29.67)    1,004.3634 (33.71)     25.6933 (11.65)    1,004.1490 (34.37)     33.2673 (10.14)         2;0   0.9957 (0.03)         10           1
bench_binop_ops[+-3-bigint]      1,002.4373 (39.16)    1,062.3287 (29.80)    1,023.0939 (34.34)     17.0897 (7.75)     1,021.2716 (34.96)     16.5741 (5.05)          3;1   0.9774 (0.03)         10           1
bench_binop_ops[//-3-bigint]     1,017.4942 (39.74)    1,209.1815 (33.92)    1,084.8319 (36.42)     67.0779 (30.43)    1,067.9013 (36.56)    107.9184 (32.88)         3;0   0.9218 (0.03)         10           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Closes #5185: Benchmark for Multidim Binop Performance

@1RyanK 1RyanK force-pushed the 5185-benchmark_for_multidim_binop_performance branch from 5bf6f9d to b31a598 Compare December 18, 2025 19:11
@1RyanK 1RyanK marked this pull request as ready for review December 18, 2025 19:25
@1RyanK 1RyanK force-pushed the 5185-benchmark_for_multidim_binop_performance branch from 6f078ba to 302a19b Compare December 19, 2025 13:23
Copy link
Contributor

@ajpotts ajpotts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

NDIMS = (1, 2, 3)
OPS = ("+", "-", "*", "/", "//", "&", "|", "^")


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you annotate like this it will cache the shape and not compute it for each test:

@functools.lru_cache(maxsize=None)
def choose_shape(n, ndim): ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Benchmark for Multidim Binop Performance

2 participants