summaryrefslogtreecommitdiffstats
path: root/cpukit/libtest/t-test-rtems-measure.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/libtest/t-test-rtems-measure.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/cpukit/libtest/t-test-rtems-measure.c b/cpukit/libtest/t-test-rtems-measure.c
index b75aff0d1a..2a2376cd27 100644
--- a/cpukit/libtest/t-test-rtems-measure.c
+++ b/cpukit/libtest/t-test-rtems-measure.c
@@ -1,7 +1,16 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
*
- * Copyright (C) 2018, 2021 embedded brains GmbH
+ * @ingroup RTEMSTestFrameworkImpl
+ *
+ * @brief This source file contains the implementation of
+ * T_measure_runtime().
+ */
+
+/*
+ * Copyright (C) 2018, 2021 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -241,14 +250,14 @@ T_measure_runtime_create(const T_measure_runtime_config *config)
ctx->sample_count = config->sample_count;
ctx->samples = add_offset(ctx, sizeof(*ctx));
+ ctx->samples = align_up(ctx->samples, cache_line_size);
ctx->cache_line_size = cache_line_size;
ctx->chunk_size = chunk_size;
ctx->chunk = add_offset(ctx->samples, sample_size);
+ ctx->chunk = align_up(ctx->chunk, cache_line_size);
ctx->runner = rtems_task_self();
ctx->load_count = load_count;
ctx->load_contexts = add_offset(ctx->chunk, chunk_size);
- ctx->samples = align_up(ctx->samples, cache_line_size);
- ctx->chunk = align_up(ctx->chunk, cache_line_size);
for (i = 0; i < load_count; ++i) {
rtems_id id;
@@ -378,13 +387,12 @@ report_sorted_samples(const T_measure_runtime_context *ctx)
sample_count = ctx->sample_count;
samples = ctx->samples;
- last = 0;
- --last;
- count = 0;
+ last = samples[0];
+ v = samples[0];
+ count = 1;
- for (i = 0; i < sample_count; ++i) {
+ for (i = 1; i < sample_count; ++i) {
v = samples[i];
- ++count;
if (v != last) {
uint32_t sa;
@@ -393,24 +401,28 @@ report_sorted_samples(const T_measure_runtime_context *ctx)
uint32_t nsb;
T_time t;
- T_time_to_seconds_and_nanoseconds(T_ticks_to_time(last),
- &sa, &nsa);
- t = T_ticks_to_time(v);
- T_time_to_seconds_and_nanoseconds(t, &sb, &nsb);
+ t = T_ticks_to_time(last);
+ T_time_to_seconds_and_nanoseconds(t, &sa, &nsa);
+ T_time_to_seconds_and_nanoseconds(T_ticks_to_time(v),
+ &sb, &nsb);
if (sa != sb || nsa != nsb) {
T_printf("M:S:%zu:%s\n", count,
T_time_to_string_ns(t, ts));
- count = 0;
+ count = 1;
+ } else {
+ ++count;
}
last = v;
+ } else {
+ ++count;
}
}
if (count > 0) {
T_printf("M:S:%zu:%s\n", count,
- T_ticks_to_string_ns(last, ts));
+ T_ticks_to_string_ns(v, ts));
}
}