mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
Merge pull request #57 from sim590/benchmark-dht-log
Enabling dht log in the benchmark
This commit is contained in:
commit
a7da1b4288
7 files changed
+139
-8
No files matched your search
@@ -153,3 +153,9 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht":
|
||||
vector[unsigned] getNodeMessageStats(bool i)
|
||||
|
||||
ctypedef DhtRunner.Config Config
|
||||
|
||||
cdef extern from "opendht/log.h" namespace "dht::log":
|
||||
void enableLogging(DhtRunner& dht)
|
||||
void disableLogging(DhtRunner& dht)
|
||||
void enableFileLogging(DhtRunner& dht, const string& path)
|
||||
|
||||
@@ -132,7 +132,6 @@ class WorkBench():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
parser = argparse.ArgumentParser(description='Run, test and benchmark a '\
|
||||
'DHT network on a local virtual network with simulated packet '\
|
||||
'loss and latency.')
|
||||
@@ -148,6 +147,7 @@ if __name__ == '__main__':
|
||||
ifConfArgs.add_argument('-no6', '--disable-ipv6', action="store_true", help='Enable IPv6')
|
||||
|
||||
testArgs = parser.add_argument_group('Test arguments')
|
||||
testArgs.add_argument('--bs-dht-log', action='store_true', default=False, help='Enables dht log in bootstrap.')
|
||||
testArgs.add_argument('-t', '--test', type=str, default=None, required=True, help='Specifies the test.')
|
||||
testArgs.add_argument('-o', '--opt', type=str, default=[], nargs='+',
|
||||
help='Options passed to tests routines.')
|
||||
@@ -164,16 +164,30 @@ if __name__ == '__main__':
|
||||
'Use "-m" to specify the number of producers on the DHT.'\
|
||||
'Use "-e" to specify the number of values to put on the DHT.')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
test_opt = { o : True for o in args.opt }
|
||||
|
||||
wb = WorkBench(args.ifname, args.virtual_locs, args.node_num, loss=args.loss,
|
||||
delay=args.delay, disable_ipv4=args.disable_ipv4,
|
||||
disable_ipv6=args.disable_ipv6)
|
||||
wb.create_virtual_net()
|
||||
|
||||
bootstrap = wb.get_bootstrap()
|
||||
|
||||
bs_dht_log_enabled = False
|
||||
def toggle_bs_dht_log(signum, frame):
|
||||
global bs_dht_log_enabled, bootstrap
|
||||
if bs_dht_log_enabled:
|
||||
bootstrap.front().disableLogging()
|
||||
bs_dht_log_enabled = False
|
||||
else:
|
||||
bootstrap.front().enableLogging()
|
||||
bs_dht_log_enabled = True
|
||||
signal.signal(signal.SIGUSR1, toggle_bs_dht_log)
|
||||
|
||||
if args.bs_dht_log:
|
||||
bs_dht_log_enabled = True
|
||||
bootstrap.front().enableLogging()
|
||||
|
||||
wb.create_virtual_net()
|
||||
bootstrap.resize(1)
|
||||
print("Launching", wb.node_num, "nodes (", wb.clusters, "clusters of", wb.node_per_loc, "nodes)")
|
||||
|
||||
|
||||
Reference in new issue
Block a user