1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Program to test different ways to get file info; right now it
8 * only works for solaris and OS/2.
21 #include <sys/types.h>
25 #define DEFAULT_COUNT 100000
29 char *filename
= "/etc/passwd";
31 char *filename
= "..\\stat.c";
34 static void statPRStat(void)
37 PRInt32 index
= count
;
40 PR_GetFileInfo(filename
, &finfo
);
44 static void statStat(void)
47 PRInt32 index
= count
;
50 stat(filename
, &finfo
);
54 /************************************************************************/
56 static void Measure(void (*func
)(void), const char *msg
)
58 PRIntervalTime start
, stop
;
62 start
= PR_IntervalNow();
64 stop
= PR_IntervalNow();
66 d
= (double)PR_IntervalToMicroseconds(stop
- start
);
67 tot
= PR_IntervalToMilliseconds(stop
-start
);
69 printf("%40s: %6.2f usec avg, %d msec total\n", msg
, d
/ count
, tot
);
72 int main(int argc
, char **argv
)
74 PR_Init(PR_USER_THREAD
, PR_PRIORITY_NORMAL
, 0);
78 count
= atoi(argv
[1]);
80 count
= DEFAULT_COUNT
;
83 Measure(statPRStat
, "time to call PR_GetFileInfo()");
84 Measure(statStat
, "time to call stat()");