Skip to content

Commit eed601d

Browse files
committed
update profiler
1 parent 753fa98 commit eed601d

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

lib/plots/canopy.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class Pannable extends Etch {
100100
this.outerContainerRect = this.refs.outerContainer.getBoundingClientRect()
101101

102102
this.setInitialScale(this.item)
103-
103+
104104
etch.update(this)
105105
}
106106

@@ -214,8 +214,8 @@ export class Pannable extends Etch {
214214

215215
class NodeView extends Etch {
216216
render() {
217-
let {height, width, top, left, onclick, onmouseover, onmouseout} = this.props;
218-
return <Clickable onclick={onclick}><div className='node' {...{onmouseover, onmouseout}} style={{
217+
let {height, width, top, left, onclick, classes, onmouseover, onmouseout} = this.props;
218+
return <Clickable onclick={onclick}><div className={`node ${classes.join(' ')}`} {...{onmouseover, onmouseout}} style={{
219219
height: 100*height+'%',
220220
width: 100*width +'%',
221221
top: 100*top +'%',
@@ -227,12 +227,13 @@ class NodeView extends Etch {
227227
}
228228

229229
export default class Canopy extends Etch {
230-
update({data}) {}
230+
update({data, className}) {}
231231
render() {
232-
let nodes = [];
233-
prefor(dims(this.props.data), node => nodes.push(<NodeView {...node} />));
234-
return <div className="ink-canopy">
232+
let nodes = []
233+
let className = this.props.className || ''
234+
prefor(dims(this.props.data), node => nodes.push(<NodeView {...node} />))
235+
return <div className={"ink-canopy " + className}>
235236
{nodes}
236-
</div>;
237+
</div>
237238
}
238239
}

lib/plots/profiler.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ function namestring (func, file, line) {
1616

1717
function process (view, tree) {
1818
tree.name = "Program"
19-
return prewalk(tree, ({count, children, location, func, path, line}) => ({
19+
return prewalk(tree, ({count, classes, children,
20+
location, func, path, line}) => ({
2021
count,
22+
classes,
2123
children,
2224
onmouseover: () => view.current = {func, location, line, count},
2325
onmouseout: () => view.current = null,
@@ -43,10 +45,11 @@ function flatten (tree) {
4345
}
4446

4547
export class ProfileViewer {
46-
constructor ({data, save=null}) {
48+
constructor ({data, customClass='', save=null}) {
4749
this.rawData = data
4850
this.data = process(this, data)
4951
this.save = save
52+
this.customClass = customClass
5053
this.highlights = require('../editor/highlights').profileLines(flatten(this.rawData))
5154

5255
this.toolbar = view(() => this.toolbarView(this.current))
@@ -86,7 +89,7 @@ export class ProfileViewer {
8689
}
8790

8891
render () {
89-
return <Canopy data={this.data} />
92+
return <Canopy className={this.customClass} data={this.data} />
9093
}
9194

9295
build () {

styles/canopy.less

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
padding: 1px;
1111
position: absolute;
1212
}
13+
1314
.node > div {
1415
width: 100%;
1516
height: 100%;
16-
border: solid @base-border-color 2px;
1717
border-radius: 5px;
18-
background: fade(@background-color-info,10%);
18+
border: solid fade(@background-color-info, 20%) 1px;
19+
background: fade(@background-color-info, 10%);
1920
&:hover {
20-
background: fade(@background-color-info,20%);
21+
background: fade(@background-color-info, 20%);
2122
}
2223
transition: all 0.2s;
2324

0 commit comments

Comments
 (0)