[gnome-battery-bench] TestRun: Include statistics in the JSON file we write
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] TestRun: Include statistics in the JSON file we write
- Date: Mon, 5 Jan 2015 13:01:50 +0000 (UTC)
commit cd26b4270d51233a2d5d378f9902151a86bd4a36
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Jan 2 17:30:59 2015 -0500
TestRun: Include statistics in the JSON file we write
src/test-run.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/test-run.c b/src/test-run.c
index dab23a3..27a577d 100644
--- a/src/test-run.c
+++ b/src/test-run.c
@@ -336,10 +336,37 @@ gbb_test_run_write_to_file(GbbTestRun *run,
g_free(start_string);
}
+ const GbbPowerState *start_state = gbb_test_run_get_start_state(run);
+ const GbbPowerState *end_state = gbb_test_run_get_last_state(run);
+ if (end_state != start_state) {
+ /* The statistics aren't needed for reading the data back into the UI,
+ * but are useful if the ouput files are going to be read by some other
+ * consumer.
+ */
+ GbbPowerStatistics *statistics = gbb_power_statistics_compute(start_state, end_state);
+ if (statistics->power > 0) {
+ json_builder_set_member_name(builder, "power");
+ json_builder_add_double_value(builder, statistics->power);
+ }
+ if (statistics->current > 0) {
+ json_builder_set_member_name(builder, "current");
+ json_builder_add_double_value(builder, statistics->current);
+ }
+ if (statistics->battery_life > 0) {
+ json_builder_set_member_name(builder, "estimated-life");
+ json_builder_add_double_value(builder, statistics->battery_life);
+ }
+ if (statistics->battery_life_design > 0) {
+ json_builder_set_member_name(builder, "estimated-life-design");
+ json_builder_add_double_value(builder, statistics->battery_life_design);
+ }
+
+ gbb_power_statistics_free(statistics);
+ }
+
json_builder_set_member_name(builder, "log");
json_builder_begin_array(builder);
GList *l;
- const GbbPowerState *start_state = gbb_test_run_get_start_state(run);
const GbbPowerState *last_state = NULL;
for (l = run->history->head; l; l = l->next) {
@@ -380,6 +407,7 @@ gbb_test_run_write_to_file(GbbTestRun *run,
json_builder_set_member_name(builder, "capacity");
add_int_value_1e6(builder, state->capacity_now);
}
+
json_builder_end_object(builder);
last_state = state;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]