rust-python-example icon indicating copy to clipboard operation
rust-python-example copied to clipboard

count_doubles from a python c module

Open szabolcsdombi opened this issue 5 years ago • 2 comments

First, Thank you for this repository!

This PR intends to solve #13 please re-run the benchmarks.

szabolcsdombi avatar Sep 07 '20 14:09 szabolcsdombi

------------------------------------------------------------------------------------------------- benchmark: 10 tests --------------------------------------------------------------------------------------------------
Name (time in us)                     Min                    Max                   Mean                StdDev                 Median                   IQR            Outliers         OPS            Rounds  Iterations       
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------       
test_rust_bytes_once             156.5000 (1.0)         207.8000 (1.0)         159.9294 (1.0)          2.6761 (1.0)         159.4000 (1.0)          1.8000 (1.0)       570;543  6,252.7609 (1.0)        6003           1       
test_c_module_once               351.8000 (2.25)        414.6000 (2.00)        357.4284 (2.23)         3.5594 (1.33)        356.1000 (2.23)         2.0000 (1.11)      367;331  2,797.7631 (0.45)       2742           1       
test_rust_once                   721.4000 (4.61)      1,423.9000 (6.85)        738.1786 (4.62)        25.6561 (9.59)        736.1000 (4.62)         8.1000 (4.50)        26;54  1,354.6857 (0.22)       1294           1       
test_rust                      1,196.0000 (7.64)      1,794.4000 (8.64)      1,224.7100 (7.66)        41.6832 (15.58)     1,214.4000 (7.62)        17.9500 (9.97)        50;74    816.5199 (0.13)        783           1       
test_numpy                     1,818.0000 (11.62)     2,466.1000 (11.87)     1,871.0853 (11.70)       46.6913 (17.45)     1,867.4000 (11.72)       38.1000 (21.17)       50;23    534.4492 (0.09)        490           1       
test_regex                    15,863.9000 (101.37)   22,647.3000 (108.99)   16,407.6823 (102.59)   1,184.8734 (442.75)   16,039.5500 (100.62)     187.7000 (104.28)        5;9     60.9471 (0.01)         62           1       
test_pure_python_once         24,905.0000 (159.14)   27,532.1000 (132.49)   25,479.6944 (159.32)     752.8467 (281.32)   25,132.5000 (157.67)     455.9500 (253.31)        5;5     39.2469 (0.01)         36           1       
test_python_comprehension     33,244.8000 (212.43)   34,371.5000 (165.41)   33,594.8448 (210.06)     295.6027 (110.46)   33,496.7000 (210.14)     482.7250 (268.18)       10;0     29.7665 (0.00)         29           1       
test_pure_python              33,423.2000 (213.57)   34,615.2000 (166.58)   33,829.9034 (211.53)     279.0457 (104.27)   33,770.5000 (211.86)     272.8500 (151.58)        8;3     29.5596 (0.00)         29           1       
test_itertools                37,397.7000 (238.96)   44,858.3000 (215.87)   38,425.6462 (240.27)   1,468.2177 (548.63)   38,094.5000 (238.99)   1,360.6000 (755.89)        1;1     26.0243 (0.00)         26           1       
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------       

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
============================================================================================= 10 passed, 492 warnings in 11.57s ============================================================================================== 

szabolcsdombi avatar Sep 07 '20 16:09 szabolcsdombi

If compiled manually with gcc:

gcc -O3 -march=native ./pyext-mycmodule/mycmodule.c -lpython3 -shared -o mycmodule.pyd

I get much better results:

------------------------------------------------------------------------------------------------- benchmark: 10 tests --------------------------------------------------------------------------------------------------
Name (time in us)                     Min                    Max                   Mean                StdDev                 Median                   IQR            Outliers         OPS            Rounds  Iterations       
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------       
test_rust_bytes_once             152.9000 (1.0)         427.2000 (1.74)        159.9188 (1.0)          4.4064 (1.91)        159.0000 (1.0)          2.0000 (1.54)      352;542  6,253.1738 (1.0)        6061           1
test_c_module_once               211.4000 (1.38)        245.3000 (1.0)         214.8225 (1.34)         2.3018 (1.0)         214.1000 (1.35)         1.3000 (1.0)       353;348  4,655.0068 (0.74)       4560           1       
test_rust_once                   719.3000 (4.70)        849.2000 (3.46)        730.5822 (4.57)         7.2450 (3.15)        727.9000 (4.58)         4.4000 (3.38)      159;149  1,368.7714 (0.22)       1347           1       
test_rust                      1,196.3000 (7.82)      1,996.2000 (8.14)      1,215.8037 (7.60)        49.2986 (21.42)     1,209.4000 (7.61)        10.0000 (7.69)        12;95    822.5012 (0.13)        810           1       
test_numpy                     1,804.7000 (11.80)     3,099.9000 (12.64)     1,919.8122 (12.00)      162.4525 (70.58)     1,888.9000 (11.88)       41.7250 (32.10)       22;37    520.8843 (0.08)        523           1       
test_regex                    15,929.7000 (104.18)   21,450.6000 (87.45)    16,335.6705 (102.15)     897.0156 (389.70)   16,096.9000 (101.24)     202.8000 (156.00)       3;11     61.2157 (0.01)         61           1       
test_pure_python_once         24,902.8000 (162.87)   27,150.1000 (110.68)   25,630.0771 (160.27)     754.4827 (327.78)   25,328.1000 (159.30)   1,065.2000 (819.38)        8;0     39.0167 (0.01)         35           1       
test_pure_python              33,295.4000 (217.76)   40,712.0000 (165.97)   34,889.1067 (218.17)   2,289.0466 (994.45)   33,772.7000 (212.41)   1,817.0000 (>1000.0)       4;4     28.6622 (0.00)         30           1       
test_python_comprehension     33,320.2000 (217.92)   34,917.6000 (142.35)   33,917.2793 (212.09)     384.7838 (167.16)   33,873.6000 (213.04)     311.1500 (239.35)        9;3     29.4835 (0.00)         29           1       
test_itertools                37,520.8000 (245.39)   40,848.5000 (166.52)   38,485.0480 (240.65)     949.3363 (412.43)   38,521.0000 (242.27)     937.5250 (721.17)        4;3     25.9841 (0.00)         25           1       
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

szabolcsdombi avatar Sep 07 '20 16:09 szabolcsdombi