Skip to content

Commit

Permalink
Remove sample{} from template examples
Browse files Browse the repository at this point in the history
.. when creating a user chart or a user metric the template
   code included calls to sample{}

   seemed odd to warn it was a serious performance issue
   whilst at the same time using it in the template.

.. we should just deprecate sample{} altogether, will likely
   make that change before the release of v3.6
  • Loading branch information
liversedge committed Dec 23, 2021
1 parent 0660473 commit ecb7910
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/Charts/UserChart.cpp
Expand Up @@ -1640,11 +1640,6 @@ EditUserSeriesDialog::EditUserSeriesDialog(Context *context, bool rangemode, Gen
" Data contains \"P\";\n"
" }\n"
"\n"
" sample {\n"
" # as we iterate over activity data points\n"
" count <- count + 1;\n"
" }\n"
"\n"
" finalise {\n"
" # we just fetch samples at end\n"
" xx <- samples(SECS);\n"
Expand Down
16 changes: 6 additions & 10 deletions src/Gui/Pages.cpp
Expand Up @@ -1937,7 +1937,8 @@ CustomMetricsPage::addClicked()
here.name = "My Average Power";
here.type = 1;
here.precision = 0;
here.description = "Average Power computed using Joules to account for variable recording.";
here.istime = false;
here.description = "Average Power";
here.unitsMetric = "watts";
here.unitsImperial = "watts";
here.conversion = 1.00;
Expand All @@ -1947,17 +1948,12 @@ CustomMetricsPage::addClicked()
relevant { Data contains \"P\"; }\n\
\n\
# initialise aggregating variables\n\
init { joules <- 0; seconds <- 0; }\n\
\n\
# joules = power x time, for each sample\n\
sample { \n\
joules <- joules + (POWER * RECINTSECS);\n\
seconds <- seconds + RECINTSECS;\n\
}\n\
# does nothing, update as needed\n\
init { 0; }\n\
\n\
# calculate metric value at end\n\
value { joules / seconds; }\n\
count { seconds; }\n\
value { mean(samples(POWER)); }\n\
count { count(samples(POWER)); }\n\
}";

EditUserMetricDialog editor(this, context, here);
Expand Down

0 comments on commit ecb7910

Please sign in to comment.