Skip to content

Commit c550295

Browse files
committed
add 'total time' to stats
1 parent 3a86905 commit c550295

14 files changed

+2872
-1561
lines changed

CHANGELOG

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
1.3 (2024-11-08)
2+
----------------
3+
* don't include first item in 'minimum time' (as that will always be zero)
4+
* add 'total time' to stats
5+
16
1.2 (2024-10-04)
27
----------------
38
* handle useconds roll-over when calculating times
49
* handle strace 'pid' header at start of line
510

6-
711
1.1 (2024-01-10)
812
----------------
913
* handle 'dmesg' style timestamps

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
OBJ=parse.o stats.o settings.o help.o
2-
FLAGS=-g -O2 -DPACKAGE_NAME=\"timediff\" -DPACKAGE_TARNAME=\"timediff\" -DPACKAGE_VERSION=\"1.2\" -DPACKAGE_STRING=\"timediff\ 1.2\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_LIBZ=1 -DHAVE_LIBUSEFUL_5_LIBUSEFUL_H=1 -DHAVE_LIBUSEFUL_5=1
3-
LIBS=-lUseful-5 -lz
1+
OBJ=common.o parse.o stats.o settings.o help.o
2+
FLAGS=-g -O2 -DPACKAGE_NAME=\"timediff\" -DPACKAGE_TARNAME=\"timediff\" -DPACKAGE_VERSION=\"1.3\" -DPACKAGE_STRING=\"timediff\ 1.3\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -D_FILE_OFFSET_BITS=64 -DHAVE_LIBZ=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1 -DHAVE_LIBCAP=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIBUSEFUL_5_LIBUSEFUL_H=1 -DHAVE_LIBUSEFUL_5=1
3+
LIBS=-lUseful-5 -lcap -lssl -lcrypto -lz
44
STATIC_LIBS=
55
PREFIX=/usr/local
66

77
all: $(OBJ)
88
gcc $(FLAGS) -otimediff $(OBJ) main.c $(LIBS) $(STATIC_LIBS)
99

10+
common.o: common.h common.c
11+
gcc $(FLAGS) -c common.c
12+
1013
stats.o: stats.h stats.c
1114
gcc $(FLAGS) -c stats.c
1215

Makefile.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OBJ=parse.o stats.o settings.o help.o @LIBUSEFUL_BUNDLED@
1+
OBJ=common.o parse.o stats.o settings.o help.o @LIBUSEFUL_BUNDLED@
22
FLAGS=@CFLAGS@ @DEFS@
33
LIBS=@LIBS@
44
STATIC_LIBS=@LIBUSEFUL_BUNDLED@
@@ -7,6 +7,9 @@ PREFIX=@prefix@
77
all: $(OBJ)
88
gcc $(FLAGS) -otimediff $(OBJ) main.c $(LIBS) $(STATIC_LIBS)
99

10+
common.o: common.h common.c
11+
gcc $(FLAGS) -c common.c
12+
1013
stats.o: stats.h stats.c
1114
gcc $(FLAGS) -c stats.c
1215

common.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "common.h"
2+
3+
double CalcTimediff(struct timeval *Prev, struct timeval *Curr)
4+
{
5+
double secs=0, usec=0;
6+
7+
if (Prev->tv_sec > 0)
8+
{
9+
//calcluate secs as a floating point value with millisecond resolution
10+
secs=difftime(Curr->tv_sec, Prev->tv_sec);
11+
if (Curr->tv_usec < Prev->tv_usec)
12+
{
13+
secs-=1; //we have rolled over our usec, so there's actually one fewer second
14+
usec=1000000 - Prev->tv_usec + Curr->tv_usec;
15+
}
16+
else usec=Curr->tv_usec - Prev->tv_usec;
17+
18+
secs += usec / 1000000;
19+
}
20+
21+
return(secs);
22+
}
23+
24+

common.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TIMEDIFF_COMMON_H
2+
#define TIMEDIFF_COMMON_H
3+
4+
#include "includes.h"
5+
6+
double CalcTimediff(struct timeval *Prev, struct timeval *Curr);
7+
8+
#endif

0 commit comments

Comments
 (0)