-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from shankari/move_stats_to_timeseries
Switch the stats to the timeseries, similar to the other data
- Loading branch information
Showing
9 changed files
with
290 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from timeit import default_timer | ||
|
||
class Timer(object): | ||
def __init__(self, verbose=False): | ||
self.verbose = verbose | ||
self.timer = default_timer | ||
|
||
def __enter__(self): | ||
self.start = self.timer() | ||
return self | ||
|
||
def __exit__(self, *args): | ||
end = self.timer() | ||
self.elapsed = end - self.start | ||
self.elapsed_ms = self.elapsed * 1000 # millisecs | ||
if self.verbose: | ||
print 'elapsed time: %f ms' % self.elapsed_ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
import emission.core.wrapper.wrapperbase as ecwb | ||
import enum as enum | ||
|
||
# class StatsEvent(enum.Enum): | ||
# """ | ||
# Indicates that some event happened that we want to record. | ||
# The event can have an associated duration, or can be a | ||
# """ | ||
# UNKNOWN = 0 | ||
# DISCHARGING = 1 | ||
# CHARGING = 2 | ||
# FULL = 3 | ||
# NOT_CHARGING = 4 # This is an android-only state - unsure how often we will encounter it | ||
# | ||
|
||
class Statsevent(ecwb.WrapperBase): | ||
# TODO: should this be a string or an enum | ||
# making it an enum will require us to change code every time we add a new stat, but will | ||
# make it easier to know the list of stats. Let's leave it as a string for now. | ||
props = {"name": ecwb.WrapperBase.Access.WORM, # string representing the stat. | ||
"reading": ecwb.WrapperBase.Access.WORM, # None or -1 if not present | ||
"ts": ecwb.WrapperBase.Access.WORM, | ||
"local_dt": ecwb.WrapperBase.Access.WORM, | ||
"fmt_time": ecwb.WrapperBase.Access.WORM, | ||
"client_app_version": ecwb.WrapperBase.Access.WORM, | ||
"client_os_version": ecwb.WrapperBase.Access.WORM | ||
} | ||
enums = {} | ||
geojson = [] | ||
nullable = [] | ||
local_dates = ['local_dt'] | ||
|
||
def _populateDependencies(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.