@@ -10,59 +10,102 @@ pub enum Char {
1010 Character ,
1111}
1212
13- fn vanilla ( ) -> String {
14- format ! (
15- "SELECT `{}` from `{}` where `character` = {}" ,
16- "character" ,
17- "character" . to_owned( ) ,
18- "foobar"
19- )
13+ fn small_type ( value : i32 ) -> SelectStatement {
14+ Query :: select ( )
15+ . column ( Char :: Character )
16+ . from ( Char :: Table )
17+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
18+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
19+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
20+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
21+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
22+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
23+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
24+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
25+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
26+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value) )
27+ . to_owned ( )
2028}
2129
22- fn select ( ) -> SelectStatement {
30+ fn large_type ( value : jiff :: Zoned ) -> SelectStatement {
2331 Query :: select ( )
2432 . column ( Char :: Character )
2533 . from ( Char :: Table )
26- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
27- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
28- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
29- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
30- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
31- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
32- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
33- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
34- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
35- . and_where ( Expr :: col ( Char :: Character ) . eq ( "foobar" ) )
34+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
35+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
36+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
37+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
38+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
39+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
40+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
41+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
42+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value . clone ( ) ) )
43+ . and_where ( Expr :: col ( Char :: Character ) . eq ( value ) )
3644 . to_owned ( )
3745}
3846
3947fn criterion_benchmark ( c : & mut Criterion ) {
4048 let mut group = c. benchmark_group ( "value" ) ;
41- group. bench_function ( "vanilla" , |b| b. iter ( vanilla) ) ;
42- group. bench_function ( "select" , |b| b. iter ( select) ) ;
49+ let value = black_box ( jiff:: Zoned :: now ( ) ) ;
4350
44- let select = black_box ( select ( ) ) ;
45- group. bench_function ( "select_and_build::mysql" , |b| {
46- b. iter ( || select. build ( MysqlQueryBuilder ) )
51+ group. bench_function ( "select_construction/small" , |b| {
52+ b. iter ( || small_type ( black_box ( 123 ) ) )
4753 } ) ;
48- group. bench_function ( "select_and_build::pg" , |b| {
49- b. iter ( || select. build ( PostgresQueryBuilder ) )
54+
55+ group. bench_function ( "select_construction/large" , |b| {
56+ b. iter ( || large_type ( value. clone ( ) ) )
5057 } ) ;
51- group. bench_function ( "select_and_build::sqlite" , |b| {
52- b. iter ( || select. build ( SqliteQueryBuilder ) )
58+
59+ let select_small = black_box ( small_type ( black_box ( 123 ) ) ) ;
60+ group. bench_function ( "select_and_build/small/mysql" , |b| {
61+ b. iter ( || select_small. build ( MysqlQueryBuilder ) )
62+ } ) ;
63+ group. bench_function ( "select_and_build/small/pg" , |b| {
64+ b. iter ( || select_small. build ( PostgresQueryBuilder ) )
5365 } ) ;
54- group. bench_function ( "select_and_to_string::mysql " , |b| {
55- b. iter ( || select . to_string ( MysqlQueryBuilder ) )
66+ group. bench_function ( "select_and_build/small/sqlite " , |b| {
67+ b. iter ( || select_small . build ( SqliteQueryBuilder ) )
5668 } ) ;
57- group. bench_function ( "select_and_to_string::pg " , |b| {
58- b. iter ( || select . to_string ( PostgresQueryBuilder ) )
69+ group. bench_function ( "select_and_to_string/small/mysql " , |b| {
70+ b. iter ( || select_small . to_string ( MysqlQueryBuilder ) )
5971 } ) ;
60- group. bench_function ( "select_and_to_string::sqlite" , |b| {
61- b. iter ( || select. to_string ( SqliteQueryBuilder ) )
72+ group. bench_function ( "select_and_to_string/small/pg" , |b| {
73+ b. iter ( || select_small. to_string ( PostgresQueryBuilder ) )
74+ } ) ;
75+ group. bench_function ( "select_and_to_string/small/sqlite" , |b| {
76+ b. iter ( || select_small. to_string ( SqliteQueryBuilder ) )
77+ } ) ;
78+
79+ let select_large = black_box ( large_type ( value) ) ;
80+ group. bench_function ( "select_and_build/large/mysql" , |b| {
81+ b. iter ( || select_large. build ( MysqlQueryBuilder ) )
82+ } ) ;
83+ group. bench_function ( "select_and_build/large/pg" , |b| {
84+ b. iter ( || select_large. build ( PostgresQueryBuilder ) )
85+ } ) ;
86+ group. bench_function ( "select_and_build/large/sqlite" , |b| {
87+ b. iter ( || select_large. build ( SqliteQueryBuilder ) )
88+ } ) ;
89+ group. bench_function ( "select_and_to_string/large/mysql" , |b| {
90+ b. iter ( || select_large. to_string ( MysqlQueryBuilder ) )
91+ } ) ;
92+ group. bench_function ( "select_and_to_string/large/pg" , |b| {
93+ b. iter ( || select_large. to_string ( PostgresQueryBuilder ) )
94+ } ) ;
95+ group. bench_function ( "select_and_to_string/large/sqlite" , |b| {
96+ b. iter ( || select_large. to_string ( SqliteQueryBuilder ) )
6297 } ) ;
6398
6499 group. finish ( ) ;
65100}
66101
67- criterion_group ! ( benches, criterion_benchmark) ;
102+ fn config ( ) -> Criterion {
103+ Criterion :: default ( ) . measurement_time ( std:: time:: Duration :: new ( 10 , 0 ) )
104+ }
105+
106+ criterion_group ! (
107+ name = benches;
108+ config = config( ) ;
109+ targets = criterion_benchmark
110+ ) ;
68111criterion_main ! ( benches) ;
0 commit comments