File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,6 @@ fn cl100k_base_benchmark(c: &mut Criterion) {
32
32
) ) ;
33
33
} ) ;
34
34
} ) ;
35
- c. bench_function ( "cl100k_base_tiktoken-rs" , |b| {
36
- b. iter ( || {
37
- black_box ( y. encode_with_special_tokens (
38
- & t
39
- ) ) ;
40
- } ) ;
41
- } ) ;
42
35
c. bench_function ( "cl100k_base_50atatime" , |b| {
43
36
b. iter ( || {
44
37
black_box ( t. chars ( )
@@ -57,16 +50,32 @@ fn cl100k_base_benchmark(c: &mut Criterion) {
57
50
. collect :: < Vec < _ > > ( ) ) ;
58
51
} ) ;
59
52
} ) ;
60
- let y = x. encode (
53
+ c. bench_function ( "tiktoken_rs::cl100k_base" , |b| {
54
+ b. iter ( || {
55
+ black_box ( y. encode_with_special_tokens (
56
+ & t
57
+ ) ) ;
58
+ } ) ;
59
+ } ) ;
60
+ let out = x. encode (
61
61
& t,
62
62
& SpecialTokenHandling {
63
63
default : SpecialTokenAction :: Special ,
64
64
..Default :: default ( )
65
65
}
66
66
)
67
67
. unwrap ( ) ;
68
- println ! ( "num tokens: {:?}" , y. len( ) ) ;
68
+ println ! ( "num tokens: {:?}" , out. len( ) ) ;
69
+ let est = x. estimate_num_tokens_no_special_tokens_fast ( & t, false ) ;
70
+ println ! ( "estimated num tokens: {:?}" , est) ;
69
71
}
70
72
71
- criterion_group ! ( benches, cl100k_base_benchmark) ;
72
- criterion_main ! ( benches) ;
73
+ criterion_group ! (
74
+ name = benches;
75
+ config = Criterion :: default ( )
76
+ . warm_up_time( std:: time:: Duration :: from_secs( 4 ) )
77
+ . measurement_time( std:: time:: Duration :: from_secs( 8 ) )
78
+ . sample_size( 150 ) ;
79
+ targets = cl100k_base_benchmark
80
+ ) ;
81
+ criterion_main ! ( benches) ;
You can’t perform that action at this time.
0 commit comments