Commits

Bryan O'Sullivan committed 3bebbf9

Get more numbers.

Comments (0)

Files changed (2)

benchmarks/Benchmarks.hs

          , bench "toFixed" $ whnf (toFixed 8) pi
          ]
        , bgroup "sprintf" [
-           bench "exponential" $ whnf (sprintf_exponential 3) pi
+           bench "exact" $ whnf sprintf_exact pi
+         , bench "exponential" $ whnf (sprintf_exponential 3) pi
          , bench "fixed" $ whnf (sprintf_fixed 8) pi
          , bench "generic" $ whnf (sprintf_generic 6) pi
-         , bench "generic_default" $ whnf (sprintf_generic_default 6) pi
+         , bench "generic_default" $ whnf sprintf_generic_default pi
          ]
        ]
 
-foreign import ccall safe sprintf_exponential :: CInt -> CDouble -> ()
-foreign import ccall safe sprintf_fixed :: CInt -> CDouble -> ()
-foreign import ccall safe sprintf_generic :: CInt -> CDouble -> ()
-foreign import ccall safe sprintf_generic_default :: CInt -> CDouble -> ()
+foreign import ccall unsafe sprintf_exact :: CDouble -> ()
+foreign import ccall unsafe sprintf_exponential :: CInt -> CDouble -> ()
+foreign import ccall unsafe sprintf_fixed :: CInt -> CDouble -> ()
+foreign import ccall unsafe sprintf_generic :: CInt -> CDouble -> ()
+foreign import ccall unsafe sprintf_generic_default :: CDouble -> ()

benchmarks/sprintf.c

 #include <stdio.h>
 
+void sprintf_exact(double x)
+{
+  char buf[64];
+  snprintf(buf, 64, "%a", x);
+}
+
 void sprintf_exponential(int d, double x)
 {
   char buf[64];