Skip to content

Commit e23b647

Browse files
committed
Add stats saving, refactor
1 parent c0457bd commit e23b647

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/Components/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export default class App extends React.PureComponent<Props, State> {
158158
...getCleanStats(),
159159
startTime,
160160
finishTime: startTime + EXPERIMENT_DURATION,
161+
type: this.state.renderType,
161162
},
162163
},
163164
() => {

src/Components/Stats.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from 'react'
2+
import { RenderType } from './RenderTypes'
23
export interface StatsProps {
4+
type?: RenderType
35
startTime?: number
46
finishTime?: number
57
FPS?: number
@@ -15,7 +17,20 @@ export interface StatsProps {
1517
}
1618
}
1719

18-
class Stats extends React.PureComponent<{ stats: StatsProps }> {
20+
const asTable = ({ type, FPS, shuffles, mutations, render }: StatsProps) => ({
21+
type,
22+
FPS,
23+
shuffles,
24+
'mutations.attributes': mutations.attributes || 0,
25+
'mutations.childList': mutations.childList || 0,
26+
'mutations.characterData': mutations.characterData || 0,
27+
'render.list': render.list || 0,
28+
'render.child': render.child || 0,
29+
})
30+
31+
class Stats extends React.PureComponent<{
32+
stats: StatsProps
33+
}> {
1934
render() {
2035
const stats = this.props.stats
2136
return (
@@ -94,6 +109,11 @@ class Stats extends React.PureComponent<{ stats: StatsProps }> {
94109
value={stats.render.child || 0}
95110
/>
96111
</div>
112+
<div className="footer">
113+
<button onClick={() => console.table(asTable(stats))}>
114+
Save Stats
115+
</button>
116+
</div>
97117
</fieldset>
98118
)
99119
}

src/main.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fieldset {
4444
h4 {
4545
text-align: center;
4646
}
47+
4748
}
4849
fieldset > div {
4950
display: flex;
@@ -54,6 +55,12 @@ fieldset {
5455
input {
5556
flex: 0 1 50%;
5657
}
58+
59+
&.footer {
60+
padding: 20px 0 0;
61+
justify-content: center;
62+
border-top: dashed 1px #eee;
63+
}
5764
}
5865
}
5966
$box-shadow-color: rgba(0, 0, 0, 0.3);

0 commit comments

Comments
 (0)