Hi Subrata,
Please accept the patch below.
Thanks,
Gowri
---
realtime: add iterations option in gtod_latency
At present, gtod_latency has fixed iterations of 10000000.
There is no option in test, to increase or decrease the count.
If we want to get more quantiles (i.e accuracy) of delays more
than 10000000, it can not be done right now.
Below patch adds new option '-i' to the test, to specify
iterations. If the option is not mentioned, default value of
10000000 iterations is used.
Signed-off-by: Gowrishankar M <[email protected]>
Tested-by: Gowrishankar M <[email protected]>
Acked-by: Dinakar Guniguntala <[email protected]>
Acked-by: Darren Hart <[email protected]>
Acked-by: John Stultz <[email protected]>
---
Index: ltp-full-20081231/testcases/realtime/func/gtod_latency/gtod_latency.c
===================================================================
--- ltp-full-20081231.orig/testcases/realtime/func/gtod_latency/gtod_latency.c 2009-01-30 18:51:46.000000000 +0530
+++ ltp-full-20081231/testcases/realtime/func/gtod_latency/gtod_latency.c 2009-01-30 19:03:20.000000000 +0530
@@ -55,7 +55,7 @@
#include <librttest.h>
#include <sys/mman.h>
-#define ITERATIONS 10000000
+#define DEFAULT_ITERATIONS 10000000
#define HIST_BUCKETS 20
#define SCATTER_FILENAME 0
@@ -81,13 +81,14 @@
"histogram y-axis"};
static unsigned long long latency_threshold = 0;
+static unsigned long long iterations = 0;
void stats_cmdline_help(void)
{
printf("Usage: ./gtod_latency {-[so|scatter-output] -[ho|hist-output]"
" -[st|scatter-title] -[ht|hist-title] -[sxl|scatter-xlabel]"
" -[syl|scatter-ylabel] -[hxl|hist-xlabel] -[hyl|hist-ylabel]"
- " -[lt|latency-trace]}"
+ " -[lt|latency-trace] -[i|iterations]}"
" -[help] \n");
printf("**command-line options are not supported yet for this testcase\n");
}
@@ -194,6 +195,15 @@
continue;
}
+ if (!strcmp(flag, "i") || !strcmp(flag, "iterations")) {
+ if (i + 1 == argc) {
+ printf("flag has missing argument\n");
+ return -1;
+ }
+ iterations = strtoull(argv[++i], NULL, 0);
+ continue;
+ }
+
printf("unknown flag given\n");
return -1;
}
@@ -210,12 +220,13 @@
return ns;
}
-struct timespec start_data[ITERATIONS];
-struct timespec stop_data[ITERATIONS];
+struct timespec *start_data;
+struct timespec *stop_data;
int main(int argc, char *argv[])
{
- int i, j, k, err;
+ unsigned long long i, k;
+ int j, err;
unsigned long long delta;
unsigned long long max, min;
struct sched_param param;
@@ -223,18 +234,33 @@
stats_container_t hist;
stats_quantiles_t quantiles;
- stats_container_init(&dat, ITERATIONS);
- stats_container_init(&hist, HIST_BUCKETS);
- stats_quantiles_init(&quantiles, (int)log10(ITERATIONS));
- setup();
-
- mlockall(MCL_CURRENT|MCL_FUTURE);
-
if (stats_cmdline(argc, argv) < 0) {
printf("usage: %s help\n", argv[0]);
exit(1);
}
+ if (iterations == 0)
+ iterations = DEFAULT_ITERATIONS;
+
+ start_data = calloc(iterations, sizeof(struct timespec));
+ stop_data = calloc(iterations, sizeof(struct timespec));
+ if (start_data == NULL || stop_data == NULL) {
+ if (errno == ENOMEM)
+ fprintf(stderr, "Failed to get more memory."\
+ "Try with reduced iterations\n");
+ else
+ fprintf(stderr, "calloc failed with errno = %d\n",
+ errno);
+ exit(1);
+ }
+
+ stats_container_init(&dat, iterations);
+ stats_container_init(&hist, HIST_BUCKETS);
+ stats_quantiles_init(&quantiles, (int)log10(iterations));
+ setup();
+
+ mlockall(MCL_CURRENT|MCL_FUTURE);
+
/* switch to SCHED_FIFO 99 */
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
err = sched_setscheduler(0, SCHED_FIFO, ¶m);
@@ -253,9 +279,9 @@
printf("\n----------------------\n");
printf("Gettimeofday() Latency\n");
printf("----------------------\n");
- printf("Iterations: %d\n\n", ITERATIONS);
+ printf("Iterations: %lli\n\n", iterations);
- /* collect ITERATIONS pairs of gtod calls */
+ /* collect iterations pairs of gtod calls */
max = min = 0;
if (latency_threshold) {
latency_trace_enable();
@@ -263,7 +289,7 @@
}
/* This loop runs for a long time, hence can cause soft lockups.
Calling sleep periodically avoids this. */
- for (i=0; i<(ITERATIONS/10000); i++) {
+ for (i=0; i<(iterations/10000); i++) {
for (j=0; j < 10000; j++) {
k = (i * 10000) + j;
clock_gettime(CLOCK_MONOTONIC,&start_data[k]);
@@ -271,7 +297,7 @@
}
usleep(1000);
}
- for (i = 0; i < ITERATIONS; i++) {
+ for (i = 0; i < iterations; i++) {
delta = timespec_subtract(&start_data[i], &stop_data[i]);
dat.records[i].x = i;
dat.records[i].y = delta;
@@ -282,9 +308,9 @@
}
if (latency_threshold) {
latency_trace_stop();
- if (i != ITERATIONS) {
- printf("Latency threshold (%lluus) exceeded at iteration %d\n",
- latency_threshold, i);
+ if (i != iterations) {
+ printf("Latency threshold (%lluus) exceeded "\
+ "at iteration %lli\n", latency_threshold, i);
latency_trace_print();
stats_container_resize(&dat, i + 1);
}
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list