Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats refactor #62

Merged
merged 11 commits into from Mar 5, 2019

Conversation

Projects
None yet
3 participants
@tsherif
Copy link
Member

commented Mar 4, 2019

This is becoming a substantial update so wanted to get some feedback.

It's pretty flexible now. Some general concepts:

  • Meant to be used either in "timing" mode (methods addTime, timeStart, timeEnd) or "count" mode (methods incrementCount, decrementCount, addCount, subtractCount). The idea is that the former would be used for things like render time, the latter for things like memory usage. Maybe worth it to split these modes into separate classes? Conceptually clearer, but would add to the surface area of the API.
  • StatsWidget can now associate a "formatter" with each stat, which is a function that takes a stat object as argument and returns a string. This can be used to customize the display of a stat.
  • I have a branch in Luma where I've made updates that use the new Stats and StatWidget here if you'd like to see an example of usage: https://github.com/uber/luma.gl/compare/stats-update?expand=1

tsherif added some commits Mar 1, 2019

@tsherif tsherif requested review from ibgreen and Pessimistress Mar 4, 2019

@ibgreen

ibgreen approved these changes Mar 4, 2019

Copy link
Contributor

left a comment

Looks fine, changes are reasonable!

Don't forget to update docs: https://github.com/uber-web/probe.gl/blob/master/docs/api-reference/log/stats.md

this.addCount(1);
}

// Call to decrement a accumulator (-1)

This comment has been minimized.

Copy link
@ibgreen

ibgreen Mar 4, 2019

Contributor

Typo: a => an accumulator

// next line
textCursor[1] += styles.fontSize + styles.lineSpacing;
}
this.instance.forEach(stat => {

This comment has been minimized.

Copy link
@ibgreen

ibgreen Mar 4, 2019

Contributor

Nit: this.instance => this.stats?

tsherif added some commits Mar 4, 2019

@tsherif tsherif marked this pull request as ready for review Mar 5, 2019


### addCounter
Create a new stat tracker.

This comment has been minimized.

Copy link
@Pessimistress

Pessimistress Mar 5, 2019

Contributor

What happens when I call create with a duplicate name? Can this be exchanged with get?

This comment has been minimized.

Copy link
@tsherif

tsherif Mar 5, 2019

Author Member

create would replace the existing stat with a new one. get only returns existing stats.

Now that I think about it, I don't really like that API, since I've found that it's convenient to keep references to created stats. I'm thinking I'll update get to function as "get or create" (like the old addCounter) and remove the create method.

@tsherif tsherif merged commit cf8204a into master Mar 5, 2019

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.