Permalink
Browse files

Rename C benchmarks.

--HG--
rename : benchmarks/sprintf.c => benchmarks/printf.c
rename : benchmarks/swprintf.c => benchmarks/wprintf.c
  • Loading branch information...
1 parent 6222f99 commit 5199996122367cc2d0d48132e1f54e6055dc12a5 @bos committed Jun 5, 2011
Showing with 12 additions and 22 deletions.
  1. +1 −1 .hgignore
  2. +3 −3 benchmarks/Makefile
  3. +4 −9 benchmarks/{sprintf.c → printf.c}
  4. +4 −9 benchmarks/{swprintf.c → wprintf.c}
View
@@ -1,5 +1,5 @@
^(?:cabal-dev|dist)$
-^benchmarks/(?:bm|simple|sprintf|swprintf)$
+^benchmarks/(?:bm|simple|c-printf|c-wprintf)$
\.(?:aux|eventlog|h[ip]|log|[oa]|orig|prof|ps|rej|swp)$
~$
syntax: glob
View
@@ -1,6 +1,6 @@
ghc := ghc
-programs := bm simple sprintf swprintf
+programs := bm simple c-printf c-wprintf
all: $(programs)
@@ -10,10 +10,10 @@ bm: Benchmarks.hs
simple: Simple.hs
$(ghc) -rtsopts -O -o $@ $<
-sprintf: sprintf.c
+c-printf: printf.c
$(CC) -O2 -o $@ $<
-swprintf: swprintf.c
+c-wprintf: wprintf.c
$(CC) -O2 -o $@ $<
clean:
@@ -16,13 +16,8 @@ void loop(int count)
{
int i;
- for (i = 0; i < count; i++) {
- char *s = malloc(64);
-
- sprintf(s, "hi mom %g\n", (double) i * M_PI);
-
- free(s);
- }
+ for (i = 0; i < count; i++)
+ printf("hi mom %g\n", (double) i * M_PI);
}
int main(int argc, char **argv)
@@ -38,6 +33,6 @@ int main(int argc, char **argv)
elapsed = gettime() - start;
- printf("%d iterations in %g secs (%g thousand/sec)\n", count, elapsed,
- count / elapsed / 1e3);
+ fprintf(stderr, "%d iterations in %g secs (%g thousand/sec)\n",
+ count, elapsed, count / elapsed / 1e3);
}
@@ -17,13 +17,8 @@ void loop(int count)
{
int i;
- for (i = 0; i < count; i++) {
- wchar_t *s = malloc(64 * sizeof(wchar_t));
-
- swprintf(s, 64, L"hi mom %g\n", (double) i * M_PI);
-
- free(s);
- }
+ for (i = 0; i < count; i++)
+ wprintf(L"hi mom %g\n", (double) i * M_PI);
}
int main(int argc, char **argv)
@@ -39,6 +34,6 @@ int main(int argc, char **argv)
elapsed = gettime() - start;
- printf("%d iterations in %g secs (%g thousand/sec)\n", count, elapsed,
- count / elapsed / 1e3);
+ fprintf(stderr, "%d iterations in %g secs (%g thousand/sec)\n",
+ count, elapsed, count / elapsed / 1e3);
}

0 comments on commit 5199996

Please sign in to comment.