#![deny(broken_intra_doc_links)]
#![deny(missing_docs)]
+#![cfg_attr(all(test, feature = "unstable"), feature(test))]
+#[cfg(all(test, feature = "unstable"))] extern crate test;
+
mod util;
extern crate lightning;
added_monitors.clear();
}
}
+
+#[cfg(all(test, feature = "unstable"))]
+pub mod bench {
+ use test::Bencher;
+
+ #[bench]
+ fn bench_sends(bench: &mut Bencher) {
+ let persister_a = super::FilesystemPersister::new("bench_filesystem_persister_a".to_string());
+ let persister_b = super::FilesystemPersister::new("bench_filesystem_persister_b".to_string());
+ lightning::ln::channelmanager::bench::bench_two_sends(bench, persister_a, persister_b);
+ }
+}
#![allow(bare_trait_objects)]
#![allow(ellipsis_inclusive_range_patterns)]
-#![cfg_attr(all(test, feature = "unstable"), feature(test))]
-#[cfg(all(test, feature = "unstable"))] extern crate test;
+#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]
+#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
extern crate bitcoin;
#[cfg(any(test, feature = "_test_utils"))] extern crate hex;
}
}
-#[cfg(all(test, feature = "unstable"))]
-mod benches {
+#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))]
+pub mod bench {
use chain::Listen;
use chain::chainmonitor::ChainMonitor;
+ use chain::channelmonitor::Persist;
use chain::keysinterface::{KeysManager, InMemorySigner};
use chain::transaction::OutPoint;
use ln::channelmanager::{ChainParameters, ChannelManager, PaymentHash, PaymentPreimage};
use test::Bencher;
- struct NodeHolder<'a> {
+ struct NodeHolder<'a, P: Persist<InMemorySigner>> {
node: &'a ChannelManager<InMemorySigner,
&'a ChainMonitor<InMemorySigner, &'a test_utils::TestChainSource,
&'a test_utils::TestBroadcaster, &'a test_utils::TestFeeEstimator,
- &'a test_utils::TestLogger, &'a test_utils::TestPersister>,
+ &'a test_utils::TestLogger, &'a P>,
&'a test_utils::TestBroadcaster, &'a KeysManager,
&'a test_utils::TestFeeEstimator, &'a test_utils::TestLogger>
}
+ #[cfg(test)]
#[bench]
fn bench_sends(bench: &mut Bencher) {
+ bench_two_sends(bench, test_utils::TestPersister::new(), test_utils::TestPersister::new());
+ }
+
+ pub fn bench_two_sends<P: Persist<InMemorySigner>>(bench: &mut Bencher, persister_a: P, persister_b: P) {
// Do a simple benchmark of sending a payment back and forth between two nodes.
// Note that this is unrealistic as each payment send will require at least two fsync
// calls per node.
config.own_channel_config.minimum_depth = 1;
let logger_a = test_utils::TestLogger::with_id("node a".to_owned());
- let persister_a = test_utils::TestPersister::new();
let chain_monitor_a = ChainMonitor::new(None, &tx_broadcaster, &logger_a, &fee_estimator, &persister_a);
let seed_a = [1u8; 32];
let keys_manager_a = KeysManager::new(&seed_a, 42, 42);
let node_a_holder = NodeHolder { node: &node_a };
let logger_b = test_utils::TestLogger::with_id("node a".to_owned());
- let persister_b = test_utils::TestPersister::new();
let chain_monitor_b = ChainMonitor::new(None, &tx_broadcaster, &logger_a, &fee_estimator, &persister_b);
let seed_b = [2u8; 32];
let keys_manager_b = KeysManager::new(&seed_b, 42, 42);