@@ -21,34 +21,41 @@ use std::{
2121use anyhow:: { bail, Result } ;
2222use futures:: stream:: TryStreamExt ;
2323use indicatif:: { ProgressBar , ProgressStyle } ;
24- use lazy_static:: lazy_static;
2524use mongodb:: {
2625 bson:: { doc, Bson , Document } ,
2726 options:: { Acknowledgment , ClientOptions , SelectionCriteria , WriteConcern } ,
2827 Client ,
2928} ;
29+ use once_cell:: sync:: Lazy ;
3030use serde_json:: Value ;
3131
3232use crate :: fs:: { BufReader , File } ;
3333
34- lazy_static ! {
35- static ref DATABASE_NAME : String = option_env!( "DATABASE_NAME" )
34+ static DATABASE_NAME : Lazy < String > = Lazy :: new ( || {
35+ option_env ! ( "DATABASE_NAME" )
3636 . unwrap_or ( "perftest" )
37- . to_string( ) ;
38- static ref COLL_NAME : String = option_env!( "COLL_NAME" ) . unwrap_or( "corpus" ) . to_string( ) ;
39- static ref MAX_EXECUTION_TIME : u64 = option_env!( "MAX_EXECUTION_TIME" )
37+ . to_string ( )
38+ } ) ;
39+ static COLL_NAME : Lazy < String > =
40+ Lazy :: new ( || option_env ! ( "COLL_NAME" ) . unwrap_or ( "corpus" ) . to_string ( ) ) ;
41+ static MAX_EXECUTION_TIME : Lazy < u64 > = Lazy :: new ( || {
42+ option_env ! ( "MAX_EXECUTION_TIME" )
4043 . unwrap_or ( "300" )
4144 . parse :: < u64 > ( )
42- . expect( "invalid MAX_EXECUTION_TIME" ) ;
43- static ref MIN_EXECUTION_TIME : u64 = option_env!( "MIN_EXECUTION_TIME" )
45+ . expect ( "invalid MAX_EXECUTION_TIME" )
46+ } ) ;
47+ static MIN_EXECUTION_TIME : Lazy < u64 > = Lazy :: new ( || {
48+ option_env ! ( "MIN_EXECUTION_TIME" )
4449 . unwrap_or ( "60" )
4550 . parse :: < u64 > ( )
46- . expect( "invalid MIN_EXECUTION_TIME" ) ;
47- pub static ref TARGET_ITERATION_COUNT : usize = option_env!( "TARGET_ITERATION_COUNT" )
51+ . expect ( "invalid MIN_EXECUTION_TIME" )
52+ } ) ;
53+ pub static TARGET_ITERATION_COUNT : Lazy < usize > = Lazy :: new ( || {
54+ option_env ! ( "TARGET_ITERATION_COUNT" )
4855 . unwrap_or ( "100" )
4956 . parse :: < usize > ( )
50- . expect( "invalid TARGET_ITERATION_COUNT" ) ;
51- }
57+ . expect ( "invalid TARGET_ITERATION_COUNT" )
58+ } ) ;
5259
5360#[ async_trait:: async_trait]
5461pub trait Benchmark : Sized {
@@ -145,13 +152,13 @@ pub async fn drop_database(uri: &str, database: &str) -> Result<()> {
145152 . run_command ( doc ! { "hello" : true } , None )
146153 . await ?;
147154
148- client. database ( & database) . drop ( None ) . await ?;
155+ client. database ( & database) . drop ( ) . await ?;
149156
150157 // in sharded clusters, take additional steps to ensure database is dropped completely.
151158 // see: https://www.mongodb.com/docs/manual/reference/method/db.dropDatabase/#replica-set-and-sharded-clusters
152159 let is_sharded = hello. get_str ( "msg" ) . ok ( ) == Some ( "isdbgrid" ) ;
153160 if is_sharded {
154- client. database ( & database) . drop ( None ) . await ?;
161+ client. database ( & database) . drop ( ) . await ?;
155162 for host in options. hosts {
156163 client
157164 . database ( "admin" )
0 commit comments