[pypy-commit] extradoc extradoc: add numvbers for the malloc version.
alex_gaynor
noreply at buildbot.pypy.org
Sun Jul 31 00:41:38 CEST 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: extradoc
Changeset: r3853:a08ae7b91546
Date: 2011-07-30 15:42 -0700
http://bitbucket.org/pypy/extradoc/changeset/a08ae7b91546/
Log: add numvbers for the malloc version.
diff --git a/blog/draft/string-formatting.rst b/blog/draft/string-formatting.rst
--- a/blog/draft/string-formatting.rst
+++ b/blog/draft/string-formatting.rst
@@ -47,4 +47,21 @@
performance). It took .85 seconds to execute under PyPy, and 1.63 seconds with
the compiled binary. We think this demonstrates the incredible potential of
dynamic compilation, GCC is unable to inline or unroll the ``sprintf`` call,
-because it sits inside of libc.
\ No newline at end of file
+because it sits inside of libc.
+
+Benchmarking the C code::
+
+ #include <stdio.h>
+ #include <stdlib.h>
+
+
+ int main() {
+ int i = 0;
+ for (i = 0; i < 10000000; i++) {
+ char *x = malloc(23 * sizeof(char));
+ sprintf(x, "%d %d", i, i);
+ free(x);
+ }
+ }
+
+Which as discussed above, is more comperable to the Python, takes 1.93 seconds.
\ No newline at end of file
More information about the pypy-commit
mailing list