LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2006, 03:45 AM   #1
syseeker
Member
 
Registered: Aug 2003
Posts: 66

Rep: Reputation: 15
"printf" slow down benchmark result


I have to perform performance benchmark on a slow CPU with scarce memory resource. Doing a printf as shown below slow down the performance severely (There is another 'action start/end' benchmark in main()). For eg. from 40ms -> 4000ms :O. Is there any more efficient way to get time for benchmark result??

void func(){
struct timeval sTime;
gettimeofday(&sTime, NULL);
printf("SOAP sec start: \t %ld\n", sTime.tv_sec);
printf("SOAP usec start: \t %ld\n", sTime.tv_usec);

// SOAP parsing operation

printf("SOAP sec end: \t %ld\n", sTime.tv_sec);
printf("SOAP usec end: \t %ld\n", sTime.tv_usec);
}
 
Old 06-07-2006, 05:55 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Well maybe you could get the start time store it in a variable, get the finish time, store it in a variable then do all the printing after the operations you wish to time. There will still be a little inaccuracy in the call to gettimeofday(), but that's just the effect that observing a phenomenon will affect the phenomenon being observed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cups-lpd: "Numerical result out of range" ramz Linux - General 2 07-27-2006 09:46 AM
How to port the result of "startx" to a file anchunlei Slackware 6 11-26-2004 05:11 AM
serial port I/O? what is "\r" in printf blackzone Programming 2 08-16-2004 05:24 AM
"ifconfig -a" giving odd result balajipriya Linux - Networking 0 08-11-2004 02:39 PM
"dig command" result in depth blackzone Linux - Networking 1 07-05-2004 06:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration