11use criterion:: { BenchmarkId , Criterion , criterion_group} ;
22use pricelevel:: {
3- Hash32 , Id , OrderType , OrderUpdate , PegReferenceType , PriceLevel , Side , TimeInForce ,
4- UuidGenerator ,
3+ Hash32 , Id , OrderType , OrderUpdate , PegReferenceType , Price , PriceLevel , Quantity , Side ,
4+ TimeInForce , TimestampMs , UuidGenerator ,
55} ;
66use std:: sync:: { Arc , Barrier } ;
77use std:: thread;
@@ -318,7 +318,7 @@ fn measure_concurrent_mixed_operations(thread_count: usize, iterations: u64) ->
318318 let base_id = thread_id as u64 * 1_000_000 + ( i - 1 ) ;
319319 let _ = thread_price_level. update_order ( OrderUpdate :: UpdateQuantity {
320320 order_id : Id :: from_u64 ( base_id) ,
321- new_quantity : 20 ,
321+ new_quantity : Quantity :: new ( 20 ) ,
322322 } ) ;
323323 }
324324 }
@@ -351,11 +351,11 @@ fn measure_concurrent_mixed_operations(thread_count: usize, iterations: u64) ->
351351fn create_standard_order ( id : u64 , price : u128 , quantity : u64 ) -> OrderType < ( ) > {
352352 OrderType :: Standard {
353353 id : Id :: from_u64 ( id) ,
354- price,
355- quantity,
354+ price : Price :: new ( price ) ,
355+ quantity : Quantity :: new ( quantity ) ,
356356 side : Side :: Buy ,
357357 user_id : Hash32 :: zero ( ) ,
358- timestamp : 1616823000000 ,
358+ timestamp : TimestampMs :: new ( 1616823000000 ) ,
359359 time_in_force : TimeInForce :: Gtc ,
360360 extra_fields : ( ) ,
361361 }
@@ -365,12 +365,12 @@ fn create_standard_order(id: u64, price: u128, quantity: u64) -> OrderType<()> {
365365fn create_iceberg_order ( id : u64 , price : u128 , visible : u64 , hidden : u64 ) -> OrderType < ( ) > {
366366 OrderType :: IcebergOrder {
367367 id : Id :: from_u64 ( id) ,
368- price,
369- visible_quantity : visible,
370- hidden_quantity : hidden,
368+ price : Price :: new ( price ) ,
369+ visible_quantity : Quantity :: new ( visible) ,
370+ hidden_quantity : Quantity :: new ( hidden) ,
371371 side : Side :: Buy ,
372372 user_id : Hash32 :: zero ( ) ,
373- timestamp : 1616823000000 ,
373+ timestamp : TimestampMs :: new ( 1616823000000 ) ,
374374 time_in_force : TimeInForce :: Gtc ,
375375 extra_fields : ( ) ,
376376 }
@@ -380,11 +380,11 @@ fn create_iceberg_order(id: u64, price: u128, visible: u64, hidden: u64) -> Orde
380380fn create_post_only_order ( id : u64 , price : u128 , quantity : u64 ) -> OrderType < ( ) > {
381381 OrderType :: PostOnly {
382382 id : Id :: from_u64 ( id) ,
383- price,
384- quantity,
383+ price : Price :: new ( price ) ,
384+ quantity : Quantity :: new ( quantity ) ,
385385 side : Side :: Buy ,
386386 user_id : Hash32 :: zero ( ) ,
387- timestamp : 1616823000000 ,
387+ timestamp : TimestampMs :: new ( 1616823000000 ) ,
388388 time_in_force : TimeInForce :: Gtc ,
389389 extra_fields : ( ) ,
390390 }
@@ -402,15 +402,15 @@ fn create_reserve_order(
402402) -> OrderType < ( ) > {
403403 OrderType :: ReserveOrder {
404404 id : Id :: from_u64 ( id) ,
405- price,
406- visible_quantity : visible,
407- hidden_quantity : hidden,
405+ price : Price :: new ( price ) ,
406+ visible_quantity : Quantity :: new ( visible) ,
407+ hidden_quantity : Quantity :: new ( hidden) ,
408408 side : Side :: Buy ,
409409 user_id : Hash32 :: zero ( ) ,
410- timestamp : 1616823000000 ,
410+ timestamp : TimestampMs :: new ( 1616823000000 ) ,
411411 time_in_force : TimeInForce :: Gtc ,
412- replenish_threshold : threshold,
413- replenish_amount,
412+ replenish_threshold : Quantity :: new ( threshold) ,
413+ replenish_amount : replenish_amount . map ( Quantity :: new ) ,
414414 auto_replenish,
415415 extra_fields : ( ) ,
416416 }
@@ -420,11 +420,11 @@ fn create_reserve_order(
420420fn create_pegged_order ( id : u64 , price : u128 , quantity : u64 ) -> OrderType < ( ) > {
421421 OrderType :: PeggedOrder {
422422 id : Id :: from_u64 ( id) ,
423- price,
424- quantity,
423+ price : Price :: new ( price ) ,
424+ quantity : Quantity :: new ( quantity ) ,
425425 side : Side :: Buy ,
426426 user_id : Hash32 :: zero ( ) ,
427- timestamp : 1616823000000 ,
427+ timestamp : TimestampMs :: new ( 1616823000000 ) ,
428428 time_in_force : TimeInForce :: Gtc ,
429429 reference_price_offset : -50 ,
430430 reference_price_type : PegReferenceType :: BestAsk ,
@@ -439,11 +439,11 @@ fn setup_standard_orders(order_count: u64) -> PriceLevel {
439439 for i in 0 ..order_count {
440440 let order = OrderType :: Standard {
441441 id : Id :: from_u64 ( i) ,
442- price : 10000u128 ,
443- quantity : 10 ,
442+ price : Price :: new ( 10000 ) ,
443+ quantity : Quantity :: new ( 10 ) ,
444444 side : Side :: Buy ,
445445 user_id : Hash32 :: zero ( ) ,
446- timestamp : 1616823000000 + i,
446+ timestamp : TimestampMs :: new ( 1616823000000 + i) ,
447447 time_in_force : TimeInForce :: Gtc ,
448448 extra_fields : ( ) ,
449449 } ;
0 commit comments