File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ nalgebra = {version = "0.25", optional = true}
24
24
25
25
[dev-dependencies ]
26
26
rand = " 0.8"
27
+ criterion = " 0.4"
27
28
28
29
[dependencies .morton-encoding ]
29
30
version = " ^2"
@@ -33,3 +34,8 @@ default-features = false
33
34
default = [" std" ]
34
35
std = []
35
36
nalg = [" nalgebra" ]
37
+
38
+
39
+ [[bench ]]
40
+ name = " metrics"
41
+ harness = false
Original file line number Diff line number Diff line change
1
+ use criterion:: { criterion_group, criterion_main, Criterion } ;
2
+ use lindel:: * ;
3
+
4
+ pub fn criterion_benchmark ( c : & mut Criterion ) {
5
+ c. bench_function ( "hilbert_decode" , |b| {
6
+ b. iter ( || {
7
+ let _: [ u32 ; 3 ] = hilbert_decode ( 34589430 ) ;
8
+ } )
9
+ } ) ;
10
+ c. bench_function ( "hilbert_encode" , |b| {
11
+ b. iter ( || {
12
+ let _: u128 = hilbert_encode ( [ 43u32 , 12 , 32 ] ) ;
13
+ } )
14
+ } ) ;
15
+
16
+ c. bench_function ( "morton_decode" , |b| {
17
+ b. iter ( || {
18
+ let _: [ u32 ; 3 ] = morton_decode ( 34589430 ) ;
19
+ } )
20
+ } ) ;
21
+ c. bench_function ( "morton_encode" , |b| {
22
+ b. iter ( || {
23
+ let _: u128 = morton_encode ( [ 43u32 , 12 , 32 ] ) ;
24
+ } )
25
+ } ) ;
26
+ }
27
+
28
+ criterion_group ! ( benches, criterion_benchmark) ;
29
+ criterion_main ! ( benches) ;
You can’t perform that action at this time.
0 commit comments