diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-12-28 22:11:02 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-12-29 00:19:05 +0100 |
commit | 31043334f47b75c5a56a8deccd903f81ac5fd7de (patch) | |
tree | 3355618f14af58f434164a6323db8a4816a1b6b6 /tests/benchmarks | |
parent | 361e37dc66b374b432f8db29f3169ab00fd0cd03 (diff) | |
download | libssh-31043334f47b75c5a56a8deccd903f81ac5fd7de.tar.gz libssh-31043334f47b75c5a56a8deccd903f81ac5fd7de.tar.xz libssh-31043334f47b75c5a56a8deccd903f81ac5fd7de.zip |
Export and document timestamp functions
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/benchmarks.h | 8 | ||||
-rw-r--r-- | tests/benchmarks/latency.c | 26 |
2 files changed, 27 insertions, 7 deletions
diff --git a/tests/benchmarks/benchmarks.h b/tests/benchmarks/benchmarks.h index fa32c9c9..e9979f96 100644 --- a/tests/benchmarks/benchmarks.h +++ b/tests/benchmarks/benchmarks.h @@ -25,7 +25,15 @@ #include <libssh/libssh.h> /* latency.c */ + +struct timestamp_struct { + struct timeval timestamp; +}; + int benchmarks_ping_latency (const char *host, float *average); int benchmarks_ssh_latency (ssh_session session, float *average); +void timestamp_init(struct timestamp_struct *ts); +float elapsed_time(struct timestamp_struct *ts); + #endif /* BENCHMARKS_H_ */ diff --git a/tests/benchmarks/latency.c b/tests/benchmarks/latency.c index 17379453..9d68fd3f 100644 --- a/tests/benchmarks/latency.c +++ b/tests/benchmarks/latency.c @@ -34,7 +34,7 @@ * @brief Calculates the RTT of the host with ICMP ping, and returns the * average of the calculated RTT. * @param[in] host hostname to ping. - * @param[out] average average RTT in ms. + * @param[out] average average RTT in milliseconds. * @returns 0 on success, -1 if there is an error. * @warning relies on an external ping program which may not exist on * certain OS. @@ -84,15 +84,20 @@ parseerror: return -1; } -struct timestamp_struct { - struct timeval timestamp; -}; - -static void timestamp_init(struct timestamp_struct *ts){ +/** @internal + * @brief initialize a timestamp to the current time. + * @param[out] ts A timestamp_struct pointer. + */ +void timestamp_init(struct timestamp_struct *ts){ gettimeofday(&ts->timestamp,NULL); } -static float elapsed_time(struct timestamp_struct *ts){ +/** @internal + * @brief return the elapsed time since now and the moment ts was initialized. + * @param[in] ts An initialized timestamp_struct pointer. + * @return Elapsed time in milliseconds. + */ +float elapsed_time(struct timestamp_struct *ts){ struct timeval now; time_t secdiff; long usecdiff; /* may be negative */ @@ -104,6 +109,13 @@ static float elapsed_time(struct timestamp_struct *ts){ return (float) (secdiff*1000) + ((float)usecdiff)/1000; } +/** @internal + * @brief Calculates the RTT of the host with SSH channel operations, and + * returns the average of the calculated RTT. + * @param[in] session active SSH session to test. + * @param[out] average average RTT in milliseconds. + * @returns 0 on success, -1 if there is an error. + */ int benchmarks_ssh_latency(ssh_session session, float *average){ float times[3]; struct timestamp_struct ts; |