Revision: 1101
Author: [email protected]
Date: Mon Mar 8 01:46:03 2010
Log: Abstract writing unsigned attribute values into
NYTP_write_attribute_unsigned().
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1101
Modified:
/trunk/FileHandle.h
/trunk/FileHandle.xs
/trunk/NYTProf.xs
=======================================
--- /trunk/FileHandle.h Mon Mar 8 01:45:56 2010
+++ /trunk/FileHandle.h Mon Mar 8 01:46:03 2010
@@ -51,3 +51,5 @@
const char *value, size_t value_len);
size_t NYTP_write_attribute_signed(NYTP_file ofile, const char *key,
size_t key_len, long value);
+size_t NYTP_write_attribute_unsigned(NYTP_file ofile, const char *key,
+ size_t key_len, unsigned long value);
=======================================
--- /trunk/FileHandle.xs Mon Mar 8 01:45:56 2010
+++ /trunk/FileHandle.xs Mon Mar 8 01:46:03 2010
@@ -686,6 +686,17 @@
# define CHAR_BIT 8
#endif
#define LOG_2_OVER_LOG_10 0.30103
+
+size_t
+NYTP_write_attribute_unsigned(NYTP_file ofile, const char *key,
+ size_t key_len, unsigned long value)
+{
+ /* 3: 1 for rounding errors, 1 for the '\0' */
+ char buffer[(int)(sizeof (unsigned long) * CHAR_BIT *
LOG_2_OVER_LOG_10 + 3)];
+ const size_t len = my_snprintf(buffer, sizeof(buffer), "%lu", value);
+
+ return NYTP_write_attribute_string(ofile, key, key_len, buffer, len);
+}
size_t
NYTP_write_attribute_signed(NYTP_file ofile, const char *key,
=======================================
--- /trunk/NYTProf.xs Mon Mar 8 01:45:56 2010
+++ /trunk/NYTProf.xs Mon Mar 8 01:46:03 2010
@@ -456,13 +456,13 @@
/* XXX add options, $0, etc, but beware of embedded newlines */
/* XXX would be good to adopt a proper charset & escaping for these */
/* $^T */
- NYTP_printf(out, ":%s=%lu\n", "basetime", (unsigned
long)PL_basetime);
+ NYTP_write_attribute_unsigned(out, STR_WITH_LEN("basetime"),
PL_basetime);
NYTP_write_attribute_string(out, STR_WITH_LEN("xs_version"),
STR_WITH_LEN(XS_VERSION));
NYTP_write_attribute_string(out, STR_WITH_LEN("perl_version"),
version, sizeof(version) - 1);
NYTP_write_attribute_signed(out, STR_WITH_LEN("clock_id"),
profile_clock);
- NYTP_printf(out, ":%s=%u\n", "ticks_per_sec", ticks_per_sec);
- NYTP_printf(out, ":%s=%d\n", "nv_size", (int)sizeof(NV));
- NYTP_printf(out, ":%s=%lu\n", "PL_perldb", (long unsigned
int)PL_perldb);
+ NYTP_write_attribute_unsigned(out, STR_WITH_LEN("ticks_per_sec"),
ticks_per_sec);
+ NYTP_write_attribute_unsigned(out, STR_WITH_LEN("nv_size"),
sizeof(NV));
+ NYTP_write_attribute_unsigned(out, STR_WITH_LEN("PL_perldb"),
PL_perldb);
NYTP_write_attribute_string(out, STR_WITH_LEN("application"), argv0,
len);
#ifdef HAS_ZLIB
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]