Hi,

Sorry that i have been unable to clarify my question, I here am asking question 
why the commands fopen(write mode) and open(O_CREAT) take 15-20 milliseconds 
and 5-10 milliseconds respectively on Solaris whereas they take 0 milliseconds 
on other OSes.

Basically the output of the below prog on other OSes is faster:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>

int main()
{
hrtime_t t1, t2;
unsigned long timeTaken;
FILE * fp;
int fd;

t1 = gethrtime();
fp = fopen("abcd.txt","w");
t2 = gethrtime();
if (fp == NULL)
        printf("fopen() failed, errno = %d\n", errno);
timeTaken = (long)(t2 - t1);
printf("time taken %ld\n",timeTaken);

t1 = gethrtime();
fd = open("abcd.txt", O_CREAT);
t2 = gethrtime();
if (fd < 0)
        printf("open() failed, errno = %d\n", errno);
timeTaken = (long)(t2 - t1);
printf("time taken %ld\n",timeTaken);

return 1;                                                                       
}

Regards,
Gaurav
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to