-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc65a80
Showing
6 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# mact-replay | ||
Replay your Akamai mact data in the same manner it was recorded. | ||
Macts can be replaced in `public/data.js` | ||
 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html, body { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#myDiv { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
<script src="./public/plotly.js"></script> | ||
</head> | ||
<body> | ||
<div id='myDiv'> | ||
<script src="./public/plotly.js"></script> | ||
<script src="./public/data.js"></script> | ||
<script src="./public/mact.js"></script> | ||
<script src="./public/plot.js"></script> | ||
</body> | ||
</html> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
window.parseMact = (mact) => { | ||
let points = []; | ||
mact.split(';').forEach(event => { | ||
if (event) { | ||
var [eventCount, eventType, timeStamp, x, y] = event.split(','); | ||
points.push({ | ||
x: parseInt(x), | ||
y: parseInt(y), | ||
eventType, | ||
timeStamp: parseInt(timeStamp), | ||
eventCount | ||
}); | ||
} | ||
}); | ||
return points; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
window.startTime = Date.now(); | ||
var layout = { | ||
xaxis: { | ||
range: [0, 2000] | ||
}, | ||
yaxis: { | ||
autorange: 'reversed', | ||
range: [0, 2000] | ||
} | ||
}; | ||
|
||
window.updatePlot = (parsedMacts) => { | ||
const elapsedTime = Date.now() - window.startTime; | ||
const traces = parsedMacts.map(m => { | ||
const firstTimestamp = m[0].timeStamp; | ||
const currentPoints = m.filter(p => p.timeStamp - firstTimestamp <= elapsedTime); | ||
const text = currentPoints.map(p => { | ||
return `Timestamp: ${p.timeStamp}\nCount: ${p.eventCount}` | ||
}) | ||
return { | ||
x: currentPoints.map(p => p.x), | ||
y: currentPoints.map(p => p.y), | ||
text, | ||
finalTime: m[m.length - 1].timeStamp - firstTimestamp, | ||
mode: 'markers', | ||
type: 'scatter' | ||
}; | ||
}); | ||
|
||
const lastTime = Math.max(...traces.map(t => t.finalTime)); | ||
Plotly.newPlot('myDiv', traces, layout); // Should use an update function instead of creating a new plot everytime. | ||
|
||
if(elapsedTime <= lastTime){ | ||
requestAnimationFrame(() => window.updatePlot(parsedMacts)) | ||
} | ||
} | ||
|
||
window.updatePlot(window.mactData.map(window.parseMact)) |
Large diffs are not rendered by default.
Oops, something went wrong.