coright / vsprog

Automatically exported from code.google.com/p/vsprog
Other
0 stars 0 forks source link

in progressbar (and many other places) time calculations base on clock(), which is not correct #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. checkout code (i had r1349)
2. build and install
3. programm a flash

What is the expected output? What do you see instead?
programming my STM32 flash takes around 4 seconds, measured with my wall-clock. 
r1349 vsprog output is:
[...]
writing flash |========================================%100| 0.32s used
Info:   flash programmed for 145408bytes(443.75KB/s)
[...]

what i would like to see is (generated with the attached patch):
[...]
writing flash |========================================%100| 4.03s used
Info:   flash programmed for 145408bytes(35.23KB/s)
[...]

What version of the product are you using? On what operating system?
r1349

Please provide any additional information below.

For timing calculations in pgbar.c (and many other places), the function 
clock() is used to determine current time.
The problem is, that clock() returns the processor time (consumed by the 
application), not the wall time.
(Man-page says: "The clock() function returns an approximation of processor 
time used by the program.")

The attached patch fixes the issue for the pgbar.c file, by replacing the 
clock() calls with a function that calls clock_gettime().

Original issue reported on code.google.com by andreas....@gmail.com on 15 Oct 2012 at 4:50

Attachments:

GoogleCodeExporter commented 8 years ago
sorry, forget to mention my operating system.
Its: Ubuntu Linux 12.04 64bit, Kernel 3.2.0-31-generic

Original comment by andreas....@gmail.com on 15 Oct 2012 at 4:51