-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathhostEffects.js
39 lines (34 loc) · 1.17 KB
/
hostEffects.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { add } from './math'
const COMMITTING_HOST_EFFECTS = 'Committing Host Effects'
// Update the store with the time spent while committing host effects
const getCommitHostEffectsTime = measures => {
const measurementsByMatchingName = measures.filter(
measure =>
measure.name.includes('⚛') &&
measure.name
.split('⚛ ')
.join('')
.includes(COMMITTING_HOST_EFFECTS)
)
return {
[COMMITTING_HOST_EFFECTS]: {
totalEffects: measurementsByMatchingName.map(
measurementByMatchingName => {
const measurementName = measurementByMatchingName.name
.split('⚛ ')
.join('')
const effectValue = measurementName.split(':')[1].split(' ')[1]
return Number(effectValue)
}
),
timeSpent: measurementsByMatchingName.map(measurementByMatchingName => {
const durationValue = measurementByMatchingName.duration.toFixed(2)
return Number(durationValue)
})
}
}
}
// Get total number of host effects
const getTotalEffects = store =>
Number(add(store[COMMITTING_HOST_EFFECTS].totalEffects))
export { getTotalEffects, getCommitHostEffectsTime }