summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/inrval.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/tests/inrval.c')
-rw-r--r--nsprpub/pr/tests/inrval.c131
1 files changed, 71 insertions, 60 deletions
diff --git a/nsprpub/pr/tests/inrval.c b/nsprpub/pr/tests/inrval.c
index e8eadaa36..52f7b71da 100644
--- a/nsprpub/pr/tests/inrval.c
+++ b/nsprpub/pr/tests/inrval.c
@@ -8,12 +8,12 @@
** description: Interval conversion test.
** Modification History:
** 15-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
-** The debug mode will print all of the printfs associated with this test.
-** The regress mode will be the default mode. Since the regress tool limits
+** The debug mode will print all of the printfs associated with this test.
+** The regress mode will be the default mode. Since the regress tool limits
** the output to a one line status:PASS or FAIL,all of the printf statements
-** have been handled with an if (debug_mode) statement.
+** have been handled with an if (debug_mode) statement.
** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
-** recognize the return code from tha main program.
+** recognize the return code from tha main program.
**/
/***********************************************************************
** Includes
@@ -45,25 +45,25 @@ static void TestConversions(void)
{
PRIntervalTime ticks = PR_TicksPerSecond();
- if (debug_mode) {
- PR_fprintf(output, "PR_TicksPerSecond: %ld\n\n", ticks);
- PR_fprintf(output, "PR_SecondsToInterval(1): %ld\n", PR_SecondsToInterval(1));
- PR_fprintf(output, "PR_MillisecondsToInterval(1000): %ld\n", PR_MillisecondsToInterval(1000));
- PR_fprintf(output, "PR_MicrosecondsToInterval(1000000): %ld\n\n", PR_MicrosecondsToInterval(1000000));
-
- PR_fprintf(output, "PR_SecondsToInterval(3): %ld\n", PR_SecondsToInterval(3));
- PR_fprintf(output, "PR_MillisecondsToInterval(3000): %ld\n", PR_MillisecondsToInterval(3000));
- PR_fprintf(output, "PR_MicrosecondsToInterval(3000000): %ld\n\n", PR_MicrosecondsToInterval(3000000));
-
- PR_fprintf(output, "PR_IntervalToSeconds(%ld): %ld\n", ticks, PR_IntervalToSeconds(ticks));
- PR_fprintf(output, "PR_IntervalToMilliseconds(%ld): %ld\n", ticks, PR_IntervalToMilliseconds(ticks));
- PR_fprintf(output, "PR_IntervalToMicroseconds(%ld): %ld\n\n", ticks, PR_IntervalToMicroseconds(ticks));
-
- ticks *= 3;
- PR_fprintf(output, "PR_IntervalToSeconds(%ld): %ld\n", ticks, PR_IntervalToSeconds(ticks));
- PR_fprintf(output, "PR_IntervalToMilliseconds(%ld): %ld\n", ticks, PR_IntervalToMilliseconds(ticks));
- PR_fprintf(output, "PR_IntervalToMicroseconds(%ld): %ld\n\n", ticks, PR_IntervalToMicroseconds(ticks));
- } /*end debug mode */
+ if (debug_mode) {
+ PR_fprintf(output, "PR_TicksPerSecond: %ld\n\n", ticks);
+ PR_fprintf(output, "PR_SecondsToInterval(1): %ld\n", PR_SecondsToInterval(1));
+ PR_fprintf(output, "PR_MillisecondsToInterval(1000): %ld\n", PR_MillisecondsToInterval(1000));
+ PR_fprintf(output, "PR_MicrosecondsToInterval(1000000): %ld\n\n", PR_MicrosecondsToInterval(1000000));
+
+ PR_fprintf(output, "PR_SecondsToInterval(3): %ld\n", PR_SecondsToInterval(3));
+ PR_fprintf(output, "PR_MillisecondsToInterval(3000): %ld\n", PR_MillisecondsToInterval(3000));
+ PR_fprintf(output, "PR_MicrosecondsToInterval(3000000): %ld\n\n", PR_MicrosecondsToInterval(3000000));
+
+ PR_fprintf(output, "PR_IntervalToSeconds(%ld): %ld\n", ticks, PR_IntervalToSeconds(ticks));
+ PR_fprintf(output, "PR_IntervalToMilliseconds(%ld): %ld\n", ticks, PR_IntervalToMilliseconds(ticks));
+ PR_fprintf(output, "PR_IntervalToMicroseconds(%ld): %ld\n\n", ticks, PR_IntervalToMicroseconds(ticks));
+
+ ticks *= 3;
+ PR_fprintf(output, "PR_IntervalToSeconds(%ld): %ld\n", ticks, PR_IntervalToSeconds(ticks));
+ PR_fprintf(output, "PR_IntervalToMilliseconds(%ld): %ld\n", ticks, PR_IntervalToMilliseconds(ticks));
+ PR_fprintf(output, "PR_IntervalToMicroseconds(%ld): %ld\n\n", ticks, PR_IntervalToMicroseconds(ticks));
+ } /*end debug mode */
} /* TestConversions */
static void TestIntervalOverhead(void)
@@ -72,8 +72,9 @@ static void TestIntervalOverhead(void)
PRUint32 elapsed, per_call, loops = 1000000;
PRIntervalTime timeout, timein = PR_IntervalNow();
- while (--loops > 0)
+ while (--loops > 0) {
timeout = PR_IntervalNow();
+ }
elapsed = 1000U * PR_IntervalToMicroseconds(timeout - timein);
per_call = elapsed / 1000000U;
@@ -91,8 +92,9 @@ static void TestNowOverhead(void)
LL_I2L(ten26th, 1000000);
timein = PR_Now();
- while (--loops > 0)
+ while (--loops > 0) {
timeout = PR_Now();
+ }
LL_SUB(elapsed, timeout, timein);
LL_MUL(elapsed, elapsed, ten23rd);
@@ -123,55 +125,63 @@ static void TestIntervals(void)
LL_I2L(thousand, 1000);
LL_DIV(elapsed, elapsed, thousand);
LL_L2UI(delta, elapsed);
- if (debug_mode) PR_fprintf(output,
- "TestIntervals: %swaiting %ld seconds took %ld msecs\n",
- ((rv == PR_SUCCESS) ? "" : "FAILED "), seconds, delta);
+ if (debug_mode) PR_fprintf(output,
+ "TestIntervals: %swaiting %ld seconds took %ld msecs\n",
+ ((rv == PR_SUCCESS) ? "" : "FAILED "), seconds, delta);
}
PR_DestroyCondVar(cv);
PR_DestroyLock(ml);
- if (debug_mode) PR_fprintf(output, "\n");
+ if (debug_mode) {
+ PR_fprintf(output, "\n");
+ }
} /* TestIntervals */
static PRIntn PR_CALLBACK RealMain(int argc, char** argv)
{
PRUint32 vcpu, cpus = 0, loops = 1000;
- /* The command line argument: -d is used to determine if the test is being run
- in debug mode. The regress tool requires only one line output:PASS or FAIL.
- All of the printfs associated with this test has been handled with a if (debug_mode)
- test.
- Usage: test_name -d
- */
-
- /* main test */
-
- PLOptStatus os;
- PLOptState *opt = PL_CreateOptState(argc, argv, "dl:c:");
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ /* The command line argument: -d is used to determine if the test is being run
+ in debug mode. The regress tool requires only one line output:PASS or FAIL.
+ All of the printfs associated with this test has been handled with a if (debug_mode)
+ test.
+ Usage: test_name -d
+ */
+
+ /* main test */
+
+ PLOptStatus os;
+ PLOptState *opt = PL_CreateOptState(argc, argv, "dl:c:");
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'd': /* debug mode */
- debug_mode = 1;
- break;
- case 'c': /* concurrency counter */
- cpus = atoi(opt->value);
- break;
- case 'l': /* loop counter */
- loops = atoi(opt->value);
- break;
- default:
- break;
+ case 'd': /* debug mode */
+ debug_mode = 1;
+ break;
+ case 'c': /* concurrency counter */
+ cpus = atoi(opt->value);
+ break;
+ case 'l': /* loop counter */
+ loops = atoi(opt->value);
+ break;
+ default:
+ break;
}
}
- PL_DestroyOptState(opt);
-
+ PL_DestroyOptState(opt);
+
output = PR_GetSpecialFD(PR_StandardOutput);
PR_fprintf(output, "inrval: Examine stdout to determine results.\n");
- if (cpus == 0) cpus = 8;
- if (loops == 0) loops = 1000;
+ if (cpus == 0) {
+ cpus = 8;
+ }
+ if (loops == 0) {
+ loops = 1000;
+ }
if (debug_mode > 0)
{
@@ -181,8 +191,9 @@ static PRIntn PR_CALLBACK RealMain(int argc, char** argv)
for (vcpu = 1; vcpu <= cpus; vcpu += cpus - 1)
{
- if (debug_mode)
+ if (debug_mode) {
PR_fprintf(output, "\nInrval: Using %d CPU(s)\n\n", vcpu);
+ }
PR_SetConcurrency(vcpu);
TestNowOverhead();
@@ -190,7 +201,7 @@ static PRIntn PR_CALLBACK RealMain(int argc, char** argv)
TestConversions();
TestIntervals();
}
-
+
return 0;
}
@@ -198,7 +209,7 @@ static PRIntn PR_CALLBACK RealMain(int argc, char** argv)
int main(int argc, char **argv)
{
PRIntn rv;
-
+
PR_STDIO_INIT();
rv = PR_Initialize(RealMain, argc, argv, 0);
return rv;