Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hlgr
drawing-app
Commits
140128fb
Commit
140128fb
authored
5 years ago
by
Moritz Langenstein
Browse files
Options
Downloads
Patches
Plain Diff
(ml5717) Added network->frontend benchmark to sequential dots
parent
3fab2647
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
__tests__/benchmark.test.js
+205
-57
205 additions, 57 deletions
__tests__/benchmark.test.js
with
205 additions
and
57 deletions
__tests__/benchmark.test.js
+
205
−
57
View file @
140128fb
...
...
@@ -31,16 +31,21 @@ function printBenchmark(title, iterations, results) {
process
.
stdout
.
write
(
`\n
${
title
}
(
${
iterations
}
iterations):\n`
)
for
(
const
title
in
results
)
{
const
{
time
,
packets
,
size
}
=
results
[
title
]
const
{
time
Loc
,
packets
,
size
,
timeRem
,
events
}
=
results
[
title
]
const
synchronisation
=
title
==
"
synchronisation
"
process
.
stdout
.
write
(
chalk
` {yellow ⧗} {dim
${
title
}
:} {yellow.inverse
${(
time
/
time
Loc
/
(
1
e6
*
(
synchronisation
?
1
:
iterations
))
).
toFixed
(
3
)}
ms
${
synchronisation
?
"
total
"
:
"
/ it
"
}
} {magenta.inverse
${
size
}
B} {dim in
${
packets
}
packet(s)}\n`
,
}
} => {dim
${
packets
}
packet(s)} => {magenta.inverse
${
size
}
B} => {yellow.inverse
${(
timeRem
/
(
1
e6
*
(
synchronisation
?
1
:
iterations
))
).
toFixed
(
3
)}
ms
${
synchronisation
?
"
total
"
:
"
/ it
"
}
} => {dim
${
events
}
event(s)}\n`
,
)
}
...
...
@@ -96,23 +101,30 @@ describe("drawing app mesh", () => {
it
(
"
benchmarks a single draw and erase update sequentially
"
,
()
=>
{
const
ITERATIONS
=
1000
jest
.
setTimeout
(
ITERATIONS
*
10
)
jest
.
setTimeout
(
ITERATIONS
*
(
10
+
300
)
)
const
dotIDs
=
[]
let
prevTime
let
broadcasts
=
0
let
addTime
=
0
le
t
addPackets
=
0
let
add
Loc
Time
=
0
cons
t
addPackets
=
[]
let
addSize
=
0
let
eraseTime
=
0
le
t
erasePackets
=
0
let
erase
Loc
Time
=
0
cons
t
erasePackets
=
[]
let
eraseSize
=
0
let
syncTime
le
t
syncPackets
=
0
let
sync
Loc
Time
cons
t
syncPackets
=
[]
let
syncSize
=
0
let
addRemTime
=
0
let
addEvents
=
0
let
eraseRemTime
=
0
let
eraseEvents
=
0
let
syncRemTime
=
0
let
syncEvents
=
0
let
timeout
return
new
Promise
((
resolve
)
=>
{
...
...
@@ -122,14 +134,14 @@ describe("drawing app mesh", () => {
broadcasts
+=
1
if
(
broadcasts
<=
ITERATIONS
)
{
addTime
+=
add
Loc
Time
+=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
addPackets
+=
1
addPackets
.
push
(
message
)
addSize
+=
message
.
message
.
length
}
else
{
eraseTime
+=
erase
Loc
Time
+=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
erasePackets
+=
1
erasePackets
.
push
(
message
)
eraseSize
+=
message
.
message
.
length
}
...
...
@@ -151,45 +163,159 @@ describe("drawing app mesh", () => {
prevTime
=
process
.
hrtime
()
dotIDs
.
push
(
room
.
addPath
(
dotDraw
[
0
]))
}).
then
(
()
=>
new
Promise
((
resolve
)
=>
{
sendListener
.
callback
=
(
uid
,
channel
,
message
)
=>
{
const
currTime
=
process
.
hrtime
()
syncTime
=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
})
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
sendListener
.
callback
=
(
uid
,
channel
,
message
)
=>
{
const
currTime
=
process
.
hrtime
()
syncLocTime
=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
syncPackets
+=
1
syncSize
+=
message
.
message
.
length
syncPackets
.
push
(
message
)
syncSize
+=
message
.
message
.
length
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
{
printBenchmark
(
"
single draw and erase [sequential]
"
,
ITERATIONS
,
{
addPath
:
{
time
:
addTime
,
packets
:
addPackets
,
size
:
addSize
},
extendErasureIntervals
:
{
time
:
eraseTime
,
packets
:
erasePackets
,
size
:
eraseSize
,
},
synchronisation
:
{
time
:
syncTime
,
packets
:
syncPackets
,
size
:
syncSize
,
},
})
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
}
resolve
()
},
1000
)
}
prevTime
=
process
.
hrtime
()
prevTime
=
process
.
hrtime
()
getEventListener
(
"
room
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
syncStep1
))
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
broadcasts
=
0
let
currTime
const
timeoutCallback
=
()
=>
{
broadcasts
+=
1
// TODO: can we assume that we only use one message here?
if
(
broadcasts
<=
ITERATIONS
)
{
addRemTime
+=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
}
else
{
eraseRemTime
+=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
}
getEventListener
(
"
room
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
syncStep1
))
}),
)
let
packet
if
(
broadcasts
<
ITERATIONS
)
{
packet
=
addPackets
[
broadcasts
]
}
else
if
(
broadcasts
<
ITERATIONS
*
2
)
{
packet
=
erasePackets
[
broadcasts
-
ITERATIONS
]
}
else
{
resolve
()
}
prevTime
=
process
.
hrtime
()
getEventListener
(
"
update
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
packet
))
}
updateRoom
.
addEventListener
(
"
addOrUpdatePath
"
,
()
=>
{
currTime
=
process
.
hrtime
()
addEvents
+=
1
clearTimeout
(
timeout
)
timeout
=
setTimeout
(
timeoutCallback
,
100
)
})
updateRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
()
=>
{
currTime
=
process
.
hrtime
()
if
(
broadcasts
<
ITERATIONS
)
{
addEvents
+=
1
}
else
if
(
broadcasts
<
ITERATIONS
*
2
)
{
eraseEvents
+=
1
}
clearTimeout
(
timeout
)
timeout
=
setTimeout
(
timeoutCallback
,
100
)
})
prevTime
=
process
.
hrtime
()
getEventListener
(
"
update
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
addPackets
[
0
]))
}),
)
.
then
(
()
=>
new
Promise
((
resolve
)
=>
{
syncRoom
.
addEventListener
(
"
addOrUpdatePath
"
,
()
=>
{
const
currTime
=
process
.
hrtime
()
syncRemTime
=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
syncEvents
+=
1
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
})
syncRoom
.
addEventListener
(
"
removedIntervalsChange
"
,
()
=>
{
const
currTime
=
process
.
hrtime
()
syncRemTime
=
(
currTime
[
0
]
-
prevTime
[
0
])
*
1
e9
+
(
currTime
[
1
]
-
prevTime
[
1
])
syncEvents
+=
1
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
resolve
(),
1000
)
})
prevTime
=
process
.
hrtime
()
for
(
const
syncPacket
of
syncPackets
)
{
getEventListener
(
"
sync
"
,
"
messageReceived
"
,
)(
createMessageReceivedEvent
(
syncPacket
))
}
}),
)
.
then
(()
=>
{
printBenchmark
(
"
single draw and erase [sequential]
"
,
ITERATIONS
,
{
addPath
:
{
timeLoc
:
addLocTime
,
packets
:
addPackets
.
length
,
size
:
addSize
,
timeRem
:
addRemTime
,
events
:
addEvents
,
},
extendErasureIntervals
:
{
timeLoc
:
eraseLocTime
,
packets
:
erasePackets
.
length
,
size
:
eraseSize
,
timeRem
:
eraseRemTime
,
events
:
eraseEvents
,
},
synchronisation
:
{
timeLoc
:
syncLocTime
,
packets
:
syncPackets
.
length
,
size
:
syncSize
,
timeRem
:
syncRemTime
,
events
:
syncEvents
,
},
})
})
})
it
(
"
benchmarks a single draw and erase update in parallel
"
,
()
=>
{
...
...
@@ -274,19 +400,25 @@ describe("drawing app mesh", () => {
timeout
=
setTimeout
(()
=>
{
printBenchmark
(
"
single draw and erase [parallel]
"
,
ITERATIONS
,
{
addPath
:
{
time
:
addTime
,
time
Loc
:
addTime
,
packets
:
addPackets
,
size
:
addSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
extendErasureIntervals
:
{
time
:
eraseTime
,
time
Loc
:
eraseTime
,
packets
:
erasePackets
,
size
:
eraseSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
synchronisation
:
{
time
:
syncTime
,
time
Loc
:
syncTime
,
packets
:
syncPackets
,
size
:
syncSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
})
...
...
@@ -598,16 +730,26 @@ describe("drawing app mesh", () => {
clearTimeout
(
timeout
)
timeout
=
setTimeout
(()
=>
{
printBenchmark
(
"
path draw and erase [sequential]
"
,
ITERATIONS
,
{
addPath
:
{
time
:
addTime
,
packets
:
addPackets
,
size
:
addSize
},
addPath
:
{
timeLoc
:
addTime
,
packets
:
addPackets
,
size
:
addSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
extendErasureIntervals
:
{
time
:
eraseTime
,
time
Loc
:
eraseTime
,
packets
:
erasePackets
,
size
:
eraseSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
synchronisation
:
{
time
:
syncTime
,
time
Loc
:
syncTime
,
packets
:
syncPackets
,
size
:
syncSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
})
...
...
@@ -724,19 +866,25 @@ describe("drawing app mesh", () => {
timeout
=
setTimeout
(()
=>
{
printBenchmark
(
"
path draw and erase [parallel]
"
,
ITERATIONS
,
{
addPath
:
{
time
:
addTime
,
time
Loc
:
addTime
,
packets
:
addPackets
,
size
:
addSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
extendErasureIntervals
:
{
time
:
eraseTime
,
time
Loc
:
eraseTime
,
packets
:
erasePackets
,
size
:
eraseSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
synchronisation
:
{
time
:
syncTime
,
time
Loc
:
syncTime
,
packets
:
syncPackets
,
size
:
syncSize
,
timeRem
:
-
1
,
events
:
-
1
,
},
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment