@@ -5,12 +5,9 @@ use anyhow::Result;
5
5
use coerce:: actor:: scheduler:: timer:: Timer ;
6
6
use coerce:: actor:: system:: ActorSystem ;
7
7
use coerce:: actor:: IntoActor ;
8
- use criterion:: { criterion_group, criterion_main, Criterion } ;
9
8
use moveos_config:: store_config:: RocksdbConfig ;
10
- use moveos_config:: { temp_dir , DataDirPath } ;
9
+ use moveos_config:: DataDirPath ;
11
10
use moveos_store:: { MoveOSDB , MoveOSStore } ;
12
- use rooch_framework:: natives:: default_gas_schedule;
13
- // use pprof::criterion::{Output, PProfProfiler};
14
11
use raw_store:: rocks:: RocksDB ;
15
12
use raw_store:: StoreInstance ;
16
13
use rooch_config:: da_config:: DAConfig ;
@@ -21,6 +18,7 @@ use rooch_da::proxy::DAProxy;
21
18
use rooch_executor:: actor:: executor:: ExecutorActor ;
22
19
use rooch_executor:: actor:: reader_executor:: ReaderExecutorActor ;
23
20
use rooch_executor:: proxy:: ExecutorProxy ;
21
+ use rooch_framework:: natives:: default_gas_schedule;
24
22
use rooch_indexer:: actor:: indexer:: IndexerActor ;
25
23
use rooch_indexer:: actor:: reader_indexer:: IndexerReaderActor ;
26
24
use rooch_indexer:: indexer_reader:: IndexerReader ;
@@ -31,9 +29,6 @@ use rooch_key::keystore::memory_keystore::InMemKeystore;
31
29
use rooch_proposer:: actor:: messages:: ProposeBlock ;
32
30
use rooch_proposer:: actor:: proposer:: ProposerActor ;
33
31
use rooch_proposer:: proxy:: ProposerProxy ;
34
- use rooch_rpc_api:: api:: rooch_api:: RoochAPIServer ;
35
- use rooch_rpc_api:: jsonrpc_types:: StrView ;
36
- use rooch_rpc_server:: server:: rooch_server:: RoochServer ;
37
32
use rooch_rpc_server:: service:: aggregate_service:: AggregateService ;
38
33
use rooch_rpc_server:: service:: rpc_service:: RpcService ;
39
34
use rooch_sequencer:: actor:: sequencer:: SequencerActor ;
@@ -46,73 +41,12 @@ use rooch_types::bitcoin::network::Network;
46
41
use rooch_types:: chain_id:: RoochChainID ;
47
42
use rooch_types:: transaction:: TypedTransaction ;
48
43
use std:: time:: Duration ;
49
- use tokio:: runtime:: Runtime ;
50
44
use tracing:: info;
51
45
52
46
pub const EXAMPLE_SIMPLE_BLOG_PACKAGE_NAME : & ' static str = "simple_blog" ;
53
47
pub const EXAMPLE_SIMPLE_BLOG_NAMED_ADDRESS : & str = "simple_blog" ;
54
48
55
- pub struct StoreHolder {
56
- _moveos_store : MoveOSStore ,
57
- _rooch_store : RoochStore ,
58
- _indexer_store : IndexerStore ,
59
- }
60
- fn transaction_write_benchmark ( c : & mut Criterion ) {
61
- std:: env:: set_var ( "RUST_LOG" , "error" ) ;
62
-
63
- let tempdir = temp_dir ( ) ;
64
- let keystore = InMemKeystore :: new_insecure_for_tests ( 10 ) ;
65
-
66
- let rt: Runtime = Runtime :: new ( ) . unwrap ( ) ;
67
- let ( rpc_service, _aggregate_service) =
68
- rt. block_on ( async { setup_service ( & tempdir, & keystore) . await . unwrap ( ) } ) ;
69
-
70
- let default_account = keystore. addresses ( ) [ 0 ] ;
71
- let mut test_transaction_builder = TestTransactionBuilder :: new ( default_account. into ( ) ) ;
72
- let tx = create_publish_transaction ( & test_transaction_builder, & keystore) . unwrap ( ) ;
73
- let _publish_result = rt. block_on ( async { rpc_service. execute_tx ( tx) . await . unwrap ( ) } ) ;
74
-
75
- let mut transactions = ( 1 ..500 )
76
- . cycle ( )
77
- . map ( |n| create_transaction ( & mut test_transaction_builder, & keystore, n) . unwrap ( ) ) ;
78
- c. bench_function ( "execute_tx" , |b| {
79
- b. to_async ( Runtime :: new ( ) . unwrap ( ) )
80
- . iter ( || rpc_service. execute_tx ( transactions. next ( ) . unwrap ( ) ) )
81
- } ) ;
82
- }
83
-
84
- fn transaction_query_benchmark ( c : & mut Criterion ) {
85
- let tempdir = temp_dir ( ) ;
86
- let keystore = InMemKeystore :: new_insecure_for_tests ( 10 ) ;
87
-
88
- let rt: Runtime = Runtime :: new ( ) . unwrap ( ) ;
89
- let ( rpc_service, aggregate_service) =
90
- rt. block_on ( async { setup_service ( & tempdir, & keystore) . await . unwrap ( ) } ) ;
91
- let rooch_server = RoochServer :: new ( rpc_service. clone ( ) , aggregate_service) ;
92
-
93
- let default_account = keystore. addresses ( ) [ 0 ] ;
94
- let mut test_transaction_builder = TestTransactionBuilder :: new ( default_account. into ( ) ) ;
95
- let tx = create_publish_transaction ( & test_transaction_builder, & keystore) . unwrap ( ) ;
96
- let _publish_result = rt. block_on ( async { rpc_service. execute_tx ( tx) . await . unwrap ( ) } ) ;
97
- //
98
- for n in 1 ..500 {
99
- let tx = create_transaction ( & mut test_transaction_builder, & keystore, n) . unwrap ( ) ;
100
- let _ = rt. block_on ( async { rpc_service. execute_tx ( tx) . await . unwrap ( ) } ) ;
101
- }
102
-
103
- let mut tx_orders = ( 1 ..500 ) . cycle ( ) . map ( |v| v) ;
104
- c. bench_function ( "get_transactions_by_order" , |b| {
105
- b. to_async ( Runtime :: new ( ) . unwrap ( ) ) . iter ( || {
106
- rooch_server. get_transactions_by_order (
107
- Some ( StrView ( tx_orders. next ( ) . unwrap ( ) ) ) ,
108
- None ,
109
- None ,
110
- )
111
- } )
112
- } ) ;
113
- }
114
-
115
- async fn setup_service (
49
+ pub async fn setup_service (
116
50
datadir : & DataDirPath ,
117
51
keystore : & InMemKeystore ,
118
52
) -> Result < ( RpcService , AggregateService ) > {
@@ -218,7 +152,7 @@ async fn setup_service(
218
152
Ok ( ( rpc_service, aggregate_service) )
219
153
}
220
154
221
- fn init_storage ( datadir : & DataDirPath ) -> Result < ( MoveOSStore , RoochStore ) > {
155
+ pub fn init_storage ( datadir : & DataDirPath ) -> Result < ( MoveOSStore , RoochStore ) > {
222
156
let ( rooch_db_path, moveos_db_path) = (
223
157
StoreConfig :: get_mock_rooch_store_dir ( datadir) ,
224
158
StoreConfig :: get_mock_moveos_store_dir ( datadir) ,
@@ -248,7 +182,7 @@ fn init_storage(datadir: &DataDirPath) -> Result<(MoveOSStore, RoochStore)> {
248
182
Ok ( ( moveos_store, rooch_store) )
249
183
}
250
184
251
- fn init_indexer ( datadir : & DataDirPath ) -> Result < ( IndexerStore , IndexerReader ) > {
185
+ pub fn init_indexer ( datadir : & DataDirPath ) -> Result < ( IndexerStore , IndexerReader ) > {
252
186
let indexer_db_path = IndexerConfig :: get_mock_indexer_db ( datadir) ;
253
187
let indexer_db_parent_dir = indexer_db_path
254
188
. parent ( )
@@ -269,7 +203,7 @@ fn init_indexer(datadir: &DataDirPath) -> Result<(IndexerStore, IndexerReader)>
269
203
Ok ( ( indexer_store, indexer_reader) )
270
204
}
271
205
272
- fn create_publish_transaction (
206
+ pub fn create_publish_transaction (
273
207
test_transaction_builder : & TestTransactionBuilder ,
274
208
keystore : & InMemKeystore ,
275
209
) -> Result < TypedTransaction > {
@@ -283,7 +217,7 @@ fn create_publish_transaction(
283
217
Ok ( TypedTransaction :: Rooch ( rooch_tx) )
284
218
}
285
219
286
- fn create_transaction (
220
+ pub fn create_transaction (
287
221
test_transaction_builder : & mut TestTransactionBuilder ,
288
222
keystore : & InMemKeystore ,
289
223
sequence_number : u64 ,
@@ -296,12 +230,3 @@ fn create_transaction(
296
230
keystore. sign_transaction ( & test_transaction_builder. sender . into ( ) , tx_data, None ) ?;
297
231
Ok ( TypedTransaction :: Rooch ( rooch_tx) )
298
232
}
299
-
300
- criterion_group ! {
301
- name = rooch_transaction_benches;
302
- config = Criterion :: default ( ) . sample_size( 200 ) . measurement_time( Duration :: from_secs( 10 ) ) ;
303
- // config = Criterion::default().sample_size(200).measurement_time(Duration::from_secs(10))
304
- // .with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
305
- targets = transaction_write_benchmark, transaction_query_benchmark
306
- }
307
- criterion_main ! ( rooch_transaction_benches) ;
0 commit comments