@@ -3,7 +3,12 @@ use std::time::Instant;
3
3
4
4
fn main ( ) {
5
5
better_panic:: install ( ) ;
6
- std:: fs:: create_dir_all ( "crosscheck" ) . unwrap ( ) ;
6
+
7
+ #[ cfg( feature = "crosscheck" ) ]
8
+ {
9
+ println ! ( "Cross-checking enabled" ) ;
10
+ std:: fs:: create_dir_all ( "crosscheck" ) . unwrap ( ) ;
11
+ }
7
12
8
13
let first_arg = std:: env:: args ( ) . nth ( 1 ) . unwrap_or_else ( || {
9
14
std:: path:: PathBuf :: from ( "testdata" )
@@ -23,6 +28,46 @@ fn main() {
23
28
SizeFormatterBinary :: new( maxlen as u64 )
24
29
) ;
25
30
31
+ println ! ( "{:>20} Running" , "wavelet" ) ;
32
+ let wavelet_duration = {
33
+ let ( before, eighties, after) = unsafe { input. align_to :: < u64 > ( ) } ;
34
+ println ! (
35
+ "original {:10} split {:10} {:10} {:10}" ,
36
+ input. len( ) ,
37
+ before. len( ) ,
38
+ eighties. len( ) ,
39
+ after. len( )
40
+ ) ;
41
+
42
+ let before_wavelet = Instant :: now ( ) ;
43
+ let wm = wavelet_matrix:: WaveletMatrix :: new ( eighties) ;
44
+ let res = before_wavelet. elapsed ( ) ;
45
+
46
+ {
47
+ let needle = "call (netbsd-amd64-cgo), const ENOSYS = 78
48
+ pkg syscall (netbsd-amd64-cgo), const ENOTBLK = 15
49
+ pkg syscall (netbs" ;
50
+ let needle = needle;
51
+ let needle_bytes = needle. as_bytes ( ) ;
52
+ let ( _, needle_eighties, _) = unsafe { needle_bytes. align_to :: < u64 > ( ) } ;
53
+
54
+ let mut range = 0 ..eighties. len ( ) ;
55
+ let mut lastoffset = 0 ;
56
+ for & c in needle_eighties {
57
+ let offset = wm. search_prefix ( range. clone ( ) , c, 0 ) . next ( ) . unwrap ( ) ;
58
+ range = offset..eighties. len ( ) ;
59
+ println ! (
60
+ "offset = {:x} ({:x}) text = {:?}" ,
61
+ offset * 8 ,
62
+ offset - lastoffset,
63
+ std:: str :: from_utf8( & input[ offset * 8 ..( offset + 1 ) * 8 ] )
64
+ ) ;
65
+ lastoffset = offset;
66
+ }
67
+ }
68
+ res
69
+ } ;
70
+
26
71
println ! ( "{:>20} Running" , "c" ) ;
27
72
28
73
let before_c = Instant :: now ( ) ;
@@ -66,10 +111,11 @@ fn main() {
66
111
before_huc. elapsed ( )
67
112
} ;
68
113
114
+ let s0 = format ! ( "wavelet {:?}" , wavelet_duration) ;
69
115
let s1 = format ! ( "c {:?}" , c_duration) ;
70
116
let s2 = format ! ( "rust {:?}" , rust_duration) ;
71
117
let s3 = format ! ( "rust-ref {:?}" , huc_duration) ;
72
- println ! ( "{:30 } {:30 } {:30}" , s1, s2, s3) ;
118
+ println ! ( "{:20 } {:20 } {:20} {:20}" , s0 , s1, s2, s3) ;
73
119
}
74
120
75
121
fn check_order < SA : Fn ( usize ) -> i32 > ( sa : SA , input : & [ u8 ] ) {
0 commit comments