summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-22 01:32:07 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-22 01:32:07 -0400
commit8bc89f362ad7ce69f0960ebab60be52f3c53b5db (patch)
treec58740642200ee222bd6091858f0d0aef9c46b3e
parent631d6e6eddfe566b801e4440e5254cc4f80bab8d (diff)
downloadgpsd-8bc89f362ad7ce69f0960ebab60be52f3c53b5db.tar.gz
Prfile numbers now include a per-cycle chracter count.
-rw-r--r--gps.h1
-rw-r--r--gpsd.h-tail1
-rw-r--r--gpsd_json.c6
-rwxr-xr-xgpsprof7
-rw-r--r--libgpsd_core.c9
5 files changed, 19 insertions, 5 deletions
diff --git a/gps.h b/gps.h
index f143fcfb..e814a7fe 100644
--- a/gps.h
+++ b/gps.h
@@ -1690,6 +1690,7 @@ struct gps_data_t {
#ifdef TIMING_ENABLE
timestamp_t cycle_start; /* timestamp start of this reporting cycle */
+ unsigned long cycle_count; /* characters in the cycle */
#endif /* TIMING_ENABLE */
/* pack things never reported together to reduce structure size */
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 5e48acd0..b084e0aa 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -132,6 +132,7 @@ struct gps_packet_t {
int debug; /* lexer debug level */
#ifdef TIMING_ENABLE
timestamp_t start_time; /* timestamp of first input */
+ unsigned long start_char; /* char counter at first input */
#endif /* TIMING_ENABLE */
/*
* ISGPS200 decoding context.
diff --git a/gpsd_json.c b/gpsd_json.c
index e694a431..217d5de7 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -214,8 +214,10 @@ void json_tpv_dump(const struct gps_data_t *gpsdata,
if (policy->timing)
(void)snprintf(reply + strlen(reply),
replylen - strlen(reply),
- "\"cycle_start\":%f,\"xmit_time\":%f,",
- gpsdata->cycle_start, xmit_time);
+ "\"cycle_start\":%f,\"cycle_count\":%lu,\"xmit_time\":%f,",
+ gpsdata->cycle_start,
+ gpsdata->cycle_count,
+ xmit_time);
#endif /* TIMING_ENABLE */
}
if (reply[strlen(reply) - 1] == ',')
diff --git a/gpsprof b/gpsprof
index 82e98f67..77374afa 100755
--- a/gpsprof
+++ b/gpsprof
@@ -193,6 +193,7 @@ class instrumented:
if 'xmit_time' in session.data:
self.stats.append((session.data['tag'],
gps.misc.isotime(session.data['time']),
+ session.data["cycle_count"],
session.data['cycle_start'],
session.data['xmit_time'],
time.time()))
@@ -205,8 +206,8 @@ class instrumented:
return res + "\n"
def data(self, unused):
res = ""
- for (tag, time, start, xmit, recv) in self.stats:
- res += "% 8s %2.9f %2.9f %2.9f %2.9f\n" % (tag, time, start-time, xmit-start, recv-xmit)
+ for (tag, time, chars, start, xmit, recv) in self.stats:
+ res += "% 8s %2.9f %u %2.9f %2.9f %2.9f\n" % (tag, time, chars, start-time, xmit-start, recv-xmit)
return res
def plot(self, unused, session, device):
legends = (
@@ -220,7 +221,7 @@ set key below
set key title "Raw latency data, %s, %s, %dN%d, cycle %ds"
plot \\\n'''
for (i, legend) in enumerate(legends):
- fmt += ' "-" using 0:%d title "%s" with impulses, \\\n' % (i+3, legend)
+ fmt += ' "-" using 0:%d title "%s" with impulses, \\\n' % (i+4, legend)
fmt = fmt[:-4] + "\n"
res = fmt % (title,
device['driver'], device['bps'],
diff --git a/libgpsd_core.c b/libgpsd_core.c
index a482ea75..210acb11 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -145,6 +145,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context,
session->gpsdata.dev.cycle = session->gpsdata.dev.mincycle = 1;
#ifdef TIMING_ENABLE
session->gpsdata.cycle_start = 0;
+ session->gpsdata.cycle_count = 0;
#endif /* TIMING_ENABLE */
/* tty-level initialization */
@@ -869,6 +870,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
}
}
session->packet.start_time = now;
+ session->packet.start_char = session->packet.char_counter;
}
#endif /* TIMING_ENABLE */
@@ -1000,6 +1002,13 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
&& session->device_type->parse_packet != NULL)
received |= session->device_type->parse_packet(session);
+#ifdef TIMING_ENABLE
+ /* are we going to generate a report? if so, count characters */
+ if ((received & REPORT_IS) != 0)
+ session->gpsdata.cycle_count = session->packet.char_counter - session->gpsdata.cycle_count;
+#endif /* TIMING_ENABLE */
+
+
session->gpsdata.set = ONLINE_SET | received;
#ifdef CHEAPFLOATS_ENABLE