Created
December 17, 2014 18:08
-
-
Save omo/33034edd13b8fddab7fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import sys | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
def delay_of(sync, chrd): | |
ret = [] | |
si = 0 | |
ci = 0 | |
while si < len(sync) and ci < len(chrd): | |
sbeg = sync.ts.iloc[si] | |
send = sbeg + sync.dur.iloc[si] | |
cbeg = chrd.ts.iloc[ci] | |
cend = cbeg + chrd.dur.iloc[ci] | |
if send < cbeg: | |
si = si + 1 | |
next | |
if cend < sbeg: | |
ci = ci + 1 | |
next | |
else: | |
ret.append({ 'delay': cbeg - sbeg }) | |
ci = ci + 1 | |
si = si + 1 | |
next | |
return pd.DataFrame(ret) | |
histrange = (0, 1200) | |
events_orig = json.load(open(sys.argv[1]))["traceEvents"] | |
events_mojo = json.load(open(sys.argv[2]))["traceEvents"] | |
df_orig = pd.DataFrame(events_orig).sort(["ts"]) | |
sync_orig = df_orig[df_orig.name == "SyncChannel::Send"] | |
chrd_orig = df_orig[df_orig.name == "ChannelReader::DispatchInputData"] | |
delay_orig = delay_of(sync_orig, chrd_orig) | |
df_mojo = pd.DataFrame(events_mojo).sort(["ts"]) | |
sync_mojo = df_mojo[df_mojo.name == "SyncChannel::Send"] | |
chrd_mojo = df_mojo[df_mojo.name == "ChannelMojo::OnMessageReceived"] | |
delay_mojo = delay_of(sync_mojo, chrd_mojo) | |
print len(sync_mojo), len(chrd_mojo) | |
print len(df_mojo), len(delay_mojo) | |
delay_orig.delay.hist(color='blue', alpha=0.7, bins=20, range=histrange) | |
delay_mojo.delay.hist(color='red', alpha=0.7, bins=20, range=histrange) | |
#sync_orig.dur.hist(color='blue', alpha=0.7, bins=20, range=histrange) | |
#sync_mojo.dur.hist(color='red', alpha=0.7, bins=20, range=histrange) | |
plt.show(block=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment