Sponsored Content
Top Forums Programming C program in Unix / Linux - Time differences Post 82794 by jim mcnamara on Tuesday 6th of September 2005 04:04:21 PM
Old 09-06-2005
Before jumping off the deep end into a quagmire, do this on HP UX:
Code:
cc -g -p mycode.c -o mycode
.....next let your code run...........
prof mycode

prof will give you a display of where your program's functions are spending time.
By the way, -p links a few monitoring functions into your code, so don't think something is broken whn you see them in your display.

Go from there, don't just guess that setbuf() is the problem - unless you called setbuf() to turn off buffering completely.
 

8 More Discussions You Might Find Interesting

1. Programming

Program in linux for all unix os

Hello there, I have the following mission for my internship: - Take an existing program which uses OpenGL writen in Delphi, for Windows. - Write this program in C++ for all operating systems from which the name end on a "X" So, what kind of features does this program need. - There... (1 Reply)
Discussion started by: lmnt22
1 Replies

2. Shell Programming and Scripting

Working out time differences

Hi everyone, I need to be able to write into a ksh script, a function that can look at 2 24 hour time variables and work out the difference between them. e.g job1 runs at 21:00 job2 runs at 01:00 diff = 04:00 hours I would also need negative numbers i.e where job1 runs after job2 ... (1 Reply)
Discussion started by: rik1551
1 Replies

3. Shell Programming and Scripting

Date/time differences

A thanks to all ahead of time. I've checked previous posts about this subject and can't find any that quite fit what I need. If I've missed the post could you point me there. When I do an ls -al I get the following output: -rw-r--r-- 1 staff staff 855 July 24 20:05 ... (4 Replies)
Discussion started by: gillr
4 Replies

4. Solaris

difficult time differences

:rolleyes: Hi, How to take the time diffence between start and finish time from a log file? It is like ..... started at Jun 20 23:20 . . ..... finished at Jun 21 01:40 Tryed so many ways but failed to ger exact way. :confused: Your help will be honoured. Ta........Lokesha (1 Reply)
Discussion started by: Lokesha
1 Replies

5. UNIX for Dummies Questions & Answers

Socket Handling Differences Between Linux & Unix?

Sorry if this is a stupid question! I have been developing a Java application that I am deploying on both Unix and Linux servers, which uses lots of socket handling. When the server side connection is dropped by the server un-gracefully I have been seeing close_waits and null connections. ... (0 Replies)
Discussion started by: Vinnie
0 Replies

6. Windows & DOS: Issues & Discussions

XP as a program on Unix/Linux system?

I am sure this question has been asked and answered before, also, if it is the wrong catergory, please let me know. I would like to know how, if possible to run Unix/Linux as my operating system, and then load XP as a program? (I am open to other operating systems, but it has to be able to... (3 Replies)
Discussion started by: mountainwolf
3 Replies

7. UNIX for Dummies Questions & Answers

Differences between time command and usr/bin/time

I wondered if someone could point out the differences between the time commmand and usr/bin/time and the accuracy one might have over another. Also, is there a website or two a person could maybe link for me to describe the differences? Thank you for your time. (2 Replies)
Discussion started by: icedrake
2 Replies

8. Shell Programming and Scripting

differences in linux and unix shell

hi all, can any one plz tell me that what is the difference between linux shell scripting and unix shell scripting. is there any difference at all?? if yes that what are the differences and how could it be combatted thanks in advance (1 Reply)
Discussion started by: nasir_khan
1 Replies
setbuf(3)						     Library Functions Manual							 setbuf(3)

NAME
setbuf, setvbuf, setvbuf_unlocked, setbuffer, setlinebuf - Assign buffering to a stream LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdio.h> void setbuf( FILE *stream, char *buffer); int setvbuf( FILE *stream, char *buffer, int mode, size_t size); int setvbuf_unlocked( FILE *stream, char *buffer, int mode, size_t size); void setbuffer( FILE *stream, char *buffer, int size); void setlinebuf( FILE *stream); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: setbuf(), setvbuf(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the input/output stream. Points to a character array. Determines how the stream parameter is buffered. Specifies the size of the buffer to be used. DESCRIPTION
The setbuf() function causes the character array pointed to by the buffer parameter to be used instead of an automatically allocated buf- fer. Use the setbuf() function after a stream has been opened but before it is read or written. If the buffer parameter is a null pointer, input/output is unbuffered. A constant, BUFSIZ, defined in the stdio.h header file, tells how large an array is needed: char buf[BUFSIZ]; For the setvbuf() function, the mode parameter determines how the stream parameter is buffered: Causes input/output to be fully buffered. Causes output to be line buffered. The buffer is flushed when a new line is written, the buffer is full, or input is requested. Causes input/output to be completely unbuffered. If the buffer parameter is not a null pointer, the array that the parameter points to is used for buffering instead of a buffer that is automatically allocated. The size parameter specifies the size of the buffer to be used. The constant BUFSIZ in the stdio.h header file is one buffer size. If input/output is unbuffered, the buffer and size parameters are ignored. The setbuffer() function, an alternate form of the setbuf() function, is used after stream has been opened but before it is read or written. The character array buffer, whose size is determined by the size parameter, is used instead of an automatically allocated buffer. If the buffer parameter is a null pointer, input/output is completely unbuffered. The setbuffer() function is not needed under normal circumstances, since the default file I/O buffer size is optimal. The setlinebuf() function is used to change stdout or stderr from block buffered or unbuffered to line buffered. Unlike the setbuf() and setbuffer() functions, the setlinebuf() function can be used any time the file descriptor is active. A buffer is normally obtained from the malloc() function at the time of the first getc() or putc() function on the file, except that the standard error stream, stderr, is normally not buffered. Output streams directed to terminals are always either line buffered or unbuffered. The setvbuf_unlocked() function is functionally identical to the setvbuf() function, except that setvbuf_unlocked() may be safely used only within a scope that is protected by the flockfile() and funlockfile() functions used as a pair. The caller must ensure that the stream is locked before these functions are used. RETURN VALUES
The setvbuf() and setvbuf_unlocked() functions return zero when successful. If they cannot honor the request, or if you give an invalid value in the mode argument, they return a nonzero value. NOTES
A common source of error is allocating buffer space as an automatic variable in a code block, and then failing to close the stream in the same block. ERRORS
If the following condition occurs, the setvbuf() function sets errno to the corresponding value. The file descriptor that underlies stream is invalid. RELATED INFORMATION
Functions: fopen(3), fread(3), getc(3), getwc(3), malloc(3), putc(3), putwc(3) Standards: standards(5) delim off setbuf(3)
All times are GMT -4. The time now is 10:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy