Skip to contentSkip to conversation

add iterations option in gtod_latency.

PATCH In review Giuseppe CAVALLARO 3 participants 8 messages Nov 6, 2009 – Nov 20, 2009 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add iterations option in gtod_latency.

Regards,
Peppe

[PATCH] add iterations option in gtod_latency.

This patch adds a new option for tuning the number of iterations into the gtod_latency realtime test.

Running gtod_latency on a target with limited resources it fails (ENOMEM) as soon as it try to allocate the memory for the two buffers start_data and stop_data.

Tested on i386 and sh4 architectures.

testcases/realtime/func/gtod_latency/gtod_latency.c renamed from testcases/realtime.orig/func/gtod_latency/gtod_latency.c +42 -13
@@ -81,13 +81,14 @@ char *labels[] = {"scatter plot x-axis",
 		  "histogram y-axis"};
 
 static unsigned long long latency_threshold = 0;
+static unsigned int iterations = ITERATIONS;
 
 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 @@ int stats_cmdline(int argc, char *argv[]
 			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,9 +220,6 @@ long long timespec_subtract(struct times
 	return ns;
 }
 
-struct timespec start_data[ITERATIONS];
-struct timespec stop_data[ITERATIONS];
-
 int main(int argc, char *argv[])
 {
 	int i, j, k, err;
@@ -222,16 +229,38 @@ int main(int argc, char *argv[])
 	stats_container_t dat;
 	stats_container_t hist;
 	stats_quantiles_t quantiles;
+	struct timespec *start_data;
+	struct timespec *stop_data;
 
-	stats_container_init(&dat, ITERATIONS);
+	if (stats_cmdline(argc, argv) < 0) {
+		printf("usage: %s help\n", argv[0]);
+		exit(1);
+	}
+
+	if (iterations < 10000) {
+		iterations = 10000;
+		printf("user \"iterations\" value is too small, try with %d",
+			iterations);
+	}
+
+	stats_container_init(&dat, iterations);
 	stats_container_init(&hist, HIST_BUCKETS);
-	stats_quantiles_init(&quantiles, (int)log10(ITERATIONS));
+	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]);
+	start_data = calloc(iterations, sizeof(struct timespec));
+	if (start_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		exit(1);
+	}
+	stop_data = calloc(iterations, sizeof(struct timespec));
+	if (stop_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		free(start_data);
 		exit(1);
 	}
 
@@ -253,9 +282,9 @@ int main(int argc, char *argv[])
 	printf("\n----------------------\n");
 	printf("Gettimeofday() Latency\n");
 	printf("----------------------\n");
-	printf("Iterations: %d\n\n", ITERATIONS);
+	printf("Iterations: %d\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 +292,7 @@ int main(int argc, char *argv[])
 	}
 	/* 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 +300,7 @@ int main(int argc, char *argv[])
 		}
 		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,7 +311,7 @@ int main(int argc, char *argv[])
 	}
 	if (latency_threshold) {
 		latency_trace_stop();
-		if (i != ITERATIONS) {
+		if (i != iterations) {
 			printf("Latency threshold (%lluus) exceeded at iteration %d\n",
 				latency_threshold, i);
 			latency_trace_print();

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 3 lines · Giuseppe CAVALLARO

Regards,
Peppe

Can you please add freeing resources at the end of main.

         stats_container_free(&dat);
         stats_container_free(&hist);
         stats_quantiles_free(&quantiles);

Also, you could set MIN_ITERATION to 10000 instead of hard coding inside main. Just a suggestion.

Thanks,
Gowri

Quoted 10 lines

------------------------------------------------------------------------

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

Quoted 6 lines

------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 7 lines · gowrishankar
Quoted 3 lines · Giuseppe CAVALLARO

Regards,
Peppe

Can you please add freeing resources at the end of main.

Quoted 7 lines
        stats_container_free(&dat);
        stats_container_free(&hist);
        stats_quantiles_free(&quantiles);

Also, you could set MIN_ITERATION to 10000 instead of hard coding inside main.
Just a suggestion.

patch reattached!
Peppe

Quoted 24 lines

Thanks,
Gowri

Quoted 18 lines

------------------------------------------------------------------------

------------------------------------------------------------------------------

Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment
- and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july

------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

[PATCH (RESEND)] add iterations option in gtod_latency.

This patch adds a new option for tuning the number of iterations into the gtod_latency realtime test.

Running gtod_latency on a target with limited resources it fails (ENOMEM) as soon as it try to allocate the memory for the two buffers start_data and stop_data.

Tested on i386 and sh4 architectures.

testcases/realtime/func/gtod_latency/gtod_latency.c renamed from testcases/realtime.orig/func/gtod_latency/gtod_latency.c +47 -13
@@ -56,6 +56,7 @@
 #include <sys/mman.h>
 
 #define ITERATIONS 10000000
+#define MIN_ITERATION 10000
 #define HIST_BUCKETS 20
 
 #define SCATTER_FILENAME	0
@@ -81,13 +82,14 @@ char *labels[] = {"scatter plot x-axis",
 		  "histogram y-axis"};
 
 static unsigned long long latency_threshold = 0;
+static unsigned int iterations = ITERATIONS;
 
 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 +196,15 @@ int stats_cmdline(int argc, char *argv[]
 			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,9 +221,6 @@ long long timespec_subtract(struct times
 	return ns;
 }
 
-struct timespec start_data[ITERATIONS];
-struct timespec stop_data[ITERATIONS];
-
 int main(int argc, char *argv[])
 {
 	int i, j, k, err;
@@ -222,16 +230,38 @@ int main(int argc, char *argv[])
 	stats_container_t dat;
 	stats_container_t hist;
 	stats_quantiles_t quantiles;
+	struct timespec *start_data;
+	struct timespec *stop_data;
+
+	if (stats_cmdline(argc, argv) < 0) {
+		printf("usage: %s help\n", argv[0]);
+		exit(1);
+	}
+
+	if (iterations < MIN_ITERATION) {
+		iterations = MIN_ITERATION ;
+		printf("user \"iterations\" value is too small (use: %d)\n",
+			iterations);
+	}
 
-	stats_container_init(&dat, ITERATIONS);
+	stats_container_init(&dat, iterations);
 	stats_container_init(&hist, HIST_BUCKETS);
-	stats_quantiles_init(&quantiles, (int)log10(ITERATIONS));
+	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]);
+	start_data = calloc(iterations, sizeof(struct timespec));
+	if (start_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		exit(1);
+	}
+	stop_data = calloc(iterations, sizeof(struct timespec));
+	if (stop_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		free(start_data);
 		exit(1);
 	}
 
@@ -253,9 +283,9 @@ int main(int argc, char *argv[])
 	printf("\n----------------------\n");
 	printf("Gettimeofday() Latency\n");
 	printf("----------------------\n");
-	printf("Iterations: %d\n\n", ITERATIONS);
+	printf("Iterations: %d\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 +293,7 @@ int main(int argc, char *argv[])
 	}
 	/* 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 +301,7 @@ int main(int argc, char *argv[])
 		}
 		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,7 +312,7 @@ int main(int argc, char *argv[])
 	}
 	if (latency_threshold) {
 		latency_trace_stop();
-		if (i != ITERATIONS) {
+		if (i != iterations) {
 			printf("Latency threshold (%lluus) exceeded at iteration %d\n",
 				latency_threshold, i);
 			latency_trace_print();
@@ -305,5 +335,9 @@ int main(int argc, char *argv[])
 	stats_quantiles_calc(&dat, &quantiles);
 	stats_quantiles_print(&quantiles);
 
+	stats_container_free(&dat);
+	stats_container_free(&hist);
+	stats_quantiles_free(&quantiles);
+
 	return 0;
 }

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 11 lines · Giuseppe CAVALLARO
Quoted 10 lines · gowrishankar
Quoted 3 lines · Giuseppe CAVALLARO

Regards,
Peppe

Can you please add freeing resources at the end of main.

        stats_container_free(&dat);
        stats_container_free(&hist);
        stats_quantiles_free(&quantiles);
Quoted 7 lines
Quoted 3 lines

Also, you could set MIN_ITERATION to 10000 instead of hard coding inside main.
Just a suggestion.

patch reattached!
Peppe

Patch looks neat!

I just recollected now that I had sent more or less same patch very long back, but maintainer missed it some how.

http://www.opensource-archive.org/showthread.php?t=82487

Subrata ?? :)

Thanks,
Gowri

Quoted 14 lines
Quoted 14 lines

Thanks,
Gowri

Quoted 11 lines

------------------------------------------------------------------------

------------------------------------------------------------------------------

Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment
- and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines

------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Acked-by Gowrishankar Acked-by Darren Hart Acked-by Sripathi Kodi
#4 lore raw
Quoted 12 lines · gowrishankar
Quoted 11 lines · Giuseppe CAVALLARO
Quoted 10 lines · gowrishankar
Quoted 3 lines · Giuseppe CAVALLARO

Regards,
Peppe

Can you please add freeing resources at the end of main.

        stats_container_free(&dat);
        stats_container_free(&hist);
        stats_quantiles_free(&quantiles);
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Also, you could set MIN_ITERATION to 10000 instead of hard coding inside main.
Just a suggestion.

patch reattached!

Thanks. But it fails to apply:

patching file testcases/realtime/func/gtod_latency/gtod_latency.c Hunk #1 succeeded at 57 (offset 1 line).
Hunk #3 succeeded at 197 (offset 1 line).
Hunk #5 FAILED at 230.
Hunk #6 succeeded at 285 (offset 2 lines).
Hunk #8 succeeded at 303 with fuzz 2 (offset 2 lines). Hunk #9 succeeded at 313 (offset 1 line).
Hunk #10 succeeded at 337 (offset 2 lines).

Quoted 11 lines
Quoted 2 lines

Peppe

Patch looks neat!

I just recollected now that I had sent more or less same patch very long back, but maintainer missed it some how.

http://www.opensource-archive.org/showthread.php?t=82487

Subrata ?? :)

I apolozise to have missed to see your patches. It is rare that i miss any patches. But, i can see that some other patch changing the same file was ack-ed by you. You could have reminded me during that time that it does not include changes sent by you:

http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/realtime/func/gtod_latency/gtod_latency.c?view=log,

Revision 1.10 - (view) (download) (annotate) - [select for diffs]
Mon Aug 3 10:37:50 2009 UTC (3 months ago) by subrata_modak
Branch: MAIN
Changes since 1.9: +4 -2 lines
Diff to previous 1.9
This set of 3 patches adds a new API stats_container_append to libstats. This function adds new stats_record_t to the record list in stats_container_t. It also replaces the occurrences of data->size with data->index and modifies the test-cases to call the append function. Changelog
---------
- Added index to stats_container_t struct
- Added Append function to add new stats_record_t to records list of stats_container_t
- Replaced the occurrences of data->size by data->index in libstats.c
- Modified the realtime testcases to include call to the append function.
[PATCH 3/3] libstats: Modify testcases to call the append function: This patch modifies the testcases to call the stats_container_append function.

Regards--
Subrata

Quoted 29 lines

Thanks,
Gowri

Quoted 22 lines
Quoted 21 lines

Thanks,
Gowri

Quoted 17 lines

------------------------------------------------------------------------

------------------------------------------------------------------------------

Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment
- and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july

------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Subrata,

Quoted 20 lines · Subrata Modak
Quoted 8 lines · gowrishankar
Quoted 7 lines · Giuseppe CAVALLARO
Quoted 6 lines · gowrishankar
Quoted 3 lines · Giuseppe CAVALLARO

Regards,
Peppe

Can you please add freeing resources at the end of main.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
        stats_container_free(&dat);
        stats_container_free(&hist);
        stats_quantiles_free(&quantiles);

Also, you could set MIN_ITERATION to 10000 instead of hard coding inside main.
Just a suggestion.

patch reattached!

Thanks. But it fails to apply:

Quoted 8 lines

patching file testcases/realtime/func/gtod_latency/gtod_latency.c Hunk #1 succeeded at 57 (offset 1 line).
Hunk #3 succeeded at 197 (offset 1 line).
Hunk #5 FAILED at 230.
Hunk #6 succeeded at 285 (offset 2 lines).
Hunk #8 succeeded at 303 with fuzz 2 (offset 2 lines). Hunk #9 succeeded at 313 (offset 1 line).
Hunk #10 succeeded at 337 (offset 2 lines).

you are right, the ltp-full-20090731-gtod_latency_iterations.patch has to be applied patch after the two patches below:

- - ltp-full-20090731-SH-atomic_add.patch
- - ltp-full-20090731-tsc_splitted.patch

Peppe

Quoted 30 lines
Quoted 10 lines
Quoted 2 lines

Peppe

Patch looks neat!

I just recollected now that I had sent more or less same patch very long back, but maintainer missed it some how.

http://www.opensource-archive.org/showthread.php?t=82487

Subrata ?? :)

I apolozise to have missed to see your patches. It is rare that i miss any patches. But, i can see that some other patch changing the same file was ack-ed by you. You could have reminded me during that time that it does not include changes sent by you:

http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/realtime/func/gtod_latency/gtod_latency.c?view=log,

Revision 1.10 - (view) (download) (annotate) - [select for diffs]
Mon Aug 3 10:37:50 2009 UTC (3 months ago) by subrata_modak
Branch: MAIN
Changes since 1.9: +4 -2 lines
Diff to previous 1.9
This set of 3 patches adds a new API stats_container_append to libstats. This function adds new stats_record_t to the record list in stats_container_t. It also replaces the occurrences of data->size with data->index and modifies the test-cases to call the append function. Changelog
---------
- Added index to stats_container_t struct
- Added Append function to add new stats_record_t to records list of stats_container_t
- Replaced the occurrences of data->size by data->index in libstats.c
- Modified the realtime testcases to include call to the append function.
[PATCH 3/3] libstats: Modify testcases to call the append function: This patch modifies the testcases to call the stats_container_append function.

Quoted 35 lines

Regards--
Subrata

Quoted 25 lines

Thanks,
Gowri

Quoted 20 lines
Quoted 20 lines

Thanks,
Gowri

Quoted 17 lines

------------------------------------------------------------------------

------------------------------------------------------------------------------

Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment
- and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july

------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksBaCwACgkQ2Xo3j31MSSLMswCff+LA4xYE/h9b37cMRCcjz1J2 J2wAnjwGwpggk4+H58l3/XZ5e0gQRvb4
=ZOT0
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw
In reply to a message not in the archive

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Subrata,

this is the patch reworked to be applied against the ltp cvs.

Regards
Peppe

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksGhQcACgkQ2Xo3j31MSSINMACfdqZU48hhlPJETmqJkAKppYdo HawAoLc0yJ8JB2iQ4JU+ffNXmSaZW+9z
=s7E+
-----END PGP SIGNATURE-----

[PATCH] add iterations option in gtod_latency.

This patch adds a new option for tuning the number of iterations into the gtod_latency realtime test.

Running gtod_latency on a target with limited resources it fails (ENOMEM) as soon as it try to allocate the memory for the two buffers start_data and stop_data.

Tested on i386 and sh4 architectures.

testcases/realtime/func/gtod_latency/gtod_latency.c renamed from testcases/realtime/func/gtod_latency/gtod_latency.c.orig +47 -13
@@ -57,6 +57,7 @@
 #include <sys/mman.h>
 
 #define ITERATIONS 10000000
+#define MIN_ITERATION 10000
 #define HIST_BUCKETS 20
 
 #define SCATTER_FILENAME	0
@@ -82,13 +83,14 @@ char *labels[] = {"scatter plot x-axis",
 		  "histogram y-axis"};
 
 static unsigned long long latency_threshold = 0;
+static unsigned int iterations = ITERATIONS;
 
 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");
 }
@@ -195,6 +197,15 @@ int stats_cmdline(int argc, char *argv[]
 			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;
 	}
@@ -211,9 +222,6 @@ long long timespec_subtract(struct times
 	return ns;
 }
 
-struct timespec start_data[ITERATIONS];
-struct timespec stop_data[ITERATIONS];
-
 int main(int argc, char *argv[])
 {
 	int i, j, k, err;
@@ -224,16 +232,38 @@ int main(int argc, char *argv[])
 	stats_container_t hist;
 	stats_quantiles_t quantiles;
 	stats_record_t rec;
+	struct timespec *start_data;
+	struct timespec *stop_data;
+
+	if (stats_cmdline(argc, argv) < 0) {
+		printf("usage: %s help\n", argv[0]);
+		exit(1);
+	}
+
+	if (iterations < MIN_ITERATION) {
+		iterations = MIN_ITERATION ;
+		printf("user \"iterations\" value is too small (use: %d)\n",
+			iterations);
+	}
 
-	stats_container_init(&dat, ITERATIONS);
+	stats_container_init(&dat, iterations);
 	stats_container_init(&hist, HIST_BUCKETS);
-	stats_quantiles_init(&quantiles, (int)log10(ITERATIONS));
+	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]);
+	start_data = calloc(iterations, sizeof(struct timespec));
+	if (start_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		exit(1);
+	}
+	stop_data = calloc(iterations, sizeof(struct timespec));
+	if (stop_data == NULL) {
+		printf("Memory allocation Failed (too many Iteration: %d)\n",
+			iterations);
+		free(start_data);
 		exit(1);
 	}
 
@@ -255,9 +285,9 @@ int main(int argc, char *argv[])
 	printf("\n----------------------\n");
 	printf("Gettimeofday() Latency\n");
 	printf("----------------------\n");
-	printf("Iterations: %d\n\n", ITERATIONS);
+	printf("Iterations: %d\n\n", iterations);
 
-	/* collect ITERATIONS pairs of gtod calls */
+	/* collect iterations pairs of gtod calls */
 	max = min = 0;
 	if (latency_threshold) {
 		latency_trace_enable();
@@ -265,7 +295,7 @@ int main(int argc, char *argv[])
 	}
 	/* 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]);
@@ -273,7 +303,7 @@ int main(int argc, char *argv[])
 		}
 		usleep(1000);
 	}
-	for (i = 0; i < ITERATIONS; i++) {
+	for (i = 0; i < iterations; i++) {
 		delta = timespec_subtract(&start_data[i], &stop_data[i]);
 		rec.x = i;
 		rec.y = delta;
@@ -285,7 +315,7 @@ int main(int argc, char *argv[])
 	}
 	if (latency_threshold) {
 		latency_trace_stop();
-		if (i != ITERATIONS) {
+		if (i != iterations) {
 			printf("Latency threshold (%lluus) exceeded at iteration %d\n",
 				latency_threshold, i);
 			latency_trace_print();
@@ -308,5 +338,9 @@ int main(int argc, char *argv[])
 	stats_quantiles_calc(&dat, &quantiles);
 	stats_quantiles_print(&quantiles);
 
+	stats_container_free(&dat);
+	stats_container_free(&hist);
+	stats_quantiles_free(&quantiles);
+
 	return 0;
 }

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#9 lore raw
Quoted 6 lines · Giuseppe CAVALLARO

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Subrata,

this is the patch reworked to be applied against the ltp cvs.

Great. Thanks. Added.

Regards--
Subrata

Quoted 4 lines

Regards
Peppe

Quoted 8 lines

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksGhQcACgkQ2Xo3j31MSSINMACfdqZU48hhlPJETmqJkAKppYdo HawAoLc0yJ8JB2iQ4JU+ffNXmSaZW+9z
=s7E+
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list