File tree 3 files changed +25
-2
lines changed
3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ features = ["pyo3/extension-module"]
36
36
37
37
[project .optional-dependencies ]
38
38
test = [
39
- " pytest >= 7.4.2" ,
39
+ " pytest >= 7.4.2" , " pyperf >= 2.7.0 "
40
40
]
41
41
[tool .maturin .dynamic ]
42
42
readme = {file = " README.md" , content-type = " text/markdown" }
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ impl CVM {
67
67
}
68
68
69
69
#[ pymodule]
70
- fn cvmcount ( _py : Python , m : Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
70
+ fn count_distinct ( _py : Python , m : Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
71
71
m. add_class :: < CVM > ( ) ?;
72
72
// m.add_function(wrap_pyfunction!(version, m)?)?;
73
73
Original file line number Diff line number Diff line change
1
+ import numpy as np
2
+ import pyperf
3
+ from count_distinct import CVM
4
+
5
+
6
+ def add_elems (counter , elems ):
7
+ for elem in elems :
8
+ counter .add (elem )
9
+
10
+
11
+ # Generate 10 million random 7-digit integers
12
+ random_integers = np .random .randint (low = 1000000 , high = 10000000 , size = 10_000_000 )
13
+
14
+ counter = CVM (0.8 , 0.1 , 100000 )
15
+
16
+ runner = pyperf .Runner ()
17
+ runner .bench_func (
18
+ "10 million 7-digit random positive integers" ,
19
+ add_elems ,
20
+ counter ,
21
+ random_integers ,
22
+ )
23
+ count = counter .calculate_final_result ()
You can’t perform that action at this time.
0 commit comments