mirror of
https://github.com/nmap/nmap.git
synced 2026-02-03 12:06:35 +00:00
Use TIMEVAL_FSEC_SUBTRACT for clarity
This commit is contained in:
@@ -1081,7 +1081,7 @@ int ncat_connect(void)
|
||||
struct timeval end_time;
|
||||
double time;
|
||||
gettimeofday(&end_time, NULL);
|
||||
time = TIMEVAL_MSEC_SUBTRACT(end_time, start_time) / 1000.0;
|
||||
time = TIMEVAL_FSEC_SUBTRACT(end_time, start_time);
|
||||
loguser("%lu bytes sent, %lu bytes received in %.2f seconds.\n",
|
||||
nsock_iod_get_write_count(cs.sock_nsi),
|
||||
nsock_iod_get_read_count(cs.sock_nsi), time);
|
||||
|
||||
@@ -400,7 +400,7 @@ static void output_summary() {
|
||||
|
||||
if (o.debugging && (tp%SUMMARY_DELAY == 0))
|
||||
log_write(LOG_STDOUT, "mass_rdns: %.2fs %d/%d [#: %lu, OK: %d, NX: %d, DR: %d, SF: %d, TR: %d]\n",
|
||||
TIMEVAL_MSEC_SUBTRACT(now, starttv) / 1000.0,
|
||||
TIMEVAL_FSEC_SUBTRACT(now, starttv),
|
||||
tp, stat_actual,
|
||||
(unsigned long) servs.size(), stat_ok, stat_nx, stat_dropped, stat_sf, stat_trans);
|
||||
}
|
||||
@@ -1252,11 +1252,11 @@ void nmap_mass_rdns(Target **targets, int num_targets) {
|
||||
// SF: Number of IPs that got 'Server Failure's
|
||||
// TR: Total number of transmissions necessary. The number of domains is ideal, higher is worse
|
||||
log_write(LOG_STDOUT, "DNS resolution of %d IPs took %.2fs. Mode: Async [#: %lu, OK: %d, NX: %d, DR: %d, SF: %d, TR: %d, CN: %d]\n",
|
||||
stat_actual, TIMEVAL_MSEC_SUBTRACT(now, starttv) / 1000.0,
|
||||
stat_actual, TIMEVAL_FSEC_SUBTRACT(now, starttv),
|
||||
(unsigned long) servs.size(), stat_ok, stat_nx, stat_dropped, stat_sf, stat_trans, stat_cname);
|
||||
} else {
|
||||
log_write(LOG_STDOUT, "DNS resolution of %d IPs took %.2fs. Mode: System [OK: %d, ??: %d]\n",
|
||||
stat_actual, TIMEVAL_MSEC_SUBTRACT(now, starttv) / 1000.0,
|
||||
stat_actual, TIMEVAL_FSEC_SUBTRACT(now, starttv),
|
||||
stat_ok, stat_actual - stat_ok);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ int UltraScanInfo::removeCompletedHosts() {
|
||||
if (remain && !timedout)
|
||||
log_write(LOG_STDOUT, "Completed %s against %s in %.2fs (%d %s)\n",
|
||||
scantype2str(scantype), hss->target->targetipstr(),
|
||||
TIMEVAL_MSEC_SUBTRACT(now, SPM->begin) / 1000.0, remain,
|
||||
TIMEVAL_FSEC_SUBTRACT(now, SPM->begin), remain,
|
||||
(remain == 1) ? "host left" : "hosts left");
|
||||
else if (timedout)
|
||||
log_write(LOG_STDOUT, "%s timed out during %s (%d %s)\n",
|
||||
|
||||
10
timing.cc
10
timing.cc
@@ -351,7 +351,7 @@ void RateMeter::update(double amount, const struct timeval *now) {
|
||||
"current" rate. */
|
||||
|
||||
/* How long since the last update? */
|
||||
diff = TIMEVAL_SUBTRACT(*now, last_update_tv) / 1000000.0;
|
||||
diff = TIMEVAL_FSEC_SUBTRACT(*now, last_update_tv);
|
||||
|
||||
if (diff < -current_rate_history)
|
||||
/* This happened farther in the past than we care about. */
|
||||
@@ -375,7 +375,7 @@ void RateMeter::update(double amount, const struct timeval *now) {
|
||||
if (TIMEVAL_AFTER(*now, tmp))
|
||||
interval = MAX(current_rate_history, diff);
|
||||
else
|
||||
interval = TIMEVAL_SUBTRACT(*now, start_tv) / 1000000.0;
|
||||
interval = TIMEVAL_FSEC_SUBTRACT(*now, start_tv);
|
||||
assert(diff <= interval + std::numeric_limits<double>::epsilon());
|
||||
/* If we record an amount in the very same instant that the timer is started,
|
||||
there's no way to calculate meaningful rates. Ignore it. */
|
||||
@@ -437,7 +437,7 @@ double RateMeter::elapsedTime(const struct timeval *now) const {
|
||||
end_tv = now;
|
||||
}
|
||||
|
||||
return TIMEVAL_SUBTRACT(*end_tv, start_tv) / 1000000.0;
|
||||
return TIMEVAL_FSEC_SUBTRACT(*end_tv, start_tv);
|
||||
}
|
||||
|
||||
/* Returns true if tv has been initialized; i.e., its members are not all
|
||||
@@ -722,9 +722,9 @@ bool ScanProgressMeter::beginOrEndTask(const struct timeval *now, const char *ad
|
||||
xml_newline();
|
||||
} else {
|
||||
if (!err)
|
||||
log_write(LOG_STDOUT, "Completed %s at %02d:%02d, %.2fs elapsed", scantypestr, tm.tm_hour, tm.tm_min, TIMEVAL_MSEC_SUBTRACT(*now, begin) / 1000.0);
|
||||
log_write(LOG_STDOUT, "Completed %s at %02d:%02d, %.2fs elapsed", scantypestr, tm.tm_hour, tm.tm_min, TIMEVAL_FSEC_SUBTRACT(*now, begin));
|
||||
else
|
||||
log_write(LOG_STDOUT, "Completed %s, %.2fs elapsed", scantypestr, TIMEVAL_MSEC_SUBTRACT(*now, begin) / 1000.0);
|
||||
log_write(LOG_STDOUT, "Completed %s, %.2fs elapsed", scantypestr, TIMEVAL_FSEC_SUBTRACT(*now, begin));
|
||||
xml_open_start_tag("taskend");
|
||||
xml_attribute("task", "%s", scantypestr);
|
||||
xml_attribute("time", "%lu", (unsigned long) now->tv_sec);
|
||||
|
||||
Reference in New Issue
Block a user