Hello. I found that Poly/ML very very slowly compiles (30 seconds) functions with very large count of pattern matching items (1400 items). I need to replace the pattern matching with many if-then-else. But the pattern matching works a faster for mlton and smlnj. Therefore, I want to use the pattern matching. :-) Also noticed that Poly/ML very slow for it. Even SML/NJ is faster for it.
Below is the code for benchmark and result. fun fc 0wx41 f r = f (0wx61, r) | fc 0wx42 f r = f (0wx62, r) | fc 0wx43 f r = f (0wx63, r) ... | fc 0wx1f80 f r = f (0wx3b9, f (0wx1f00, r)) | fc 0wx1f81 f r = f (0wx3b9, f (0wx1f01, r)) | fc 0wx1f82 f r = f (0wx3b9, f (0wx1f02, r)) ... | fc 0wx1e920 f r = f (0wx1e942, r) | fc 0wx1e921 f r = f (0wx1e943, r) | fc w f r = f (w, r) 1400 items fun runBench N name f = let fun loop 0 f = () | loop i f = (f (); loop (i - 1) f) val t0 = Time.now () val _ = loop N f val t1 = Time.now () in print (name ^ " " ^ Real.toString(Time.toReal(Time.-(t1, t0))) ^ "\n") end val _ = runBench 1000000 "latin a" (fn () => (fc 0w97 (op ::) [])) val _ = runBench 1000000 "Sharp s" (fn () => (fc 0wxdf (op ::) [])) val _ = runBench 1000000 "Cyr Yi " (fn () => (fc 0wx407 (op ::) [])) val _ = runBench 1000000 "last " (fn () => (fc 0wx1e921 (op ::) [])) > time poly --script unicode-case.sml ; echo "===" ; time poly --script > unicode-if.sml ; echo "===" ; time poly --script unicode-if-opt.sml latin a 4.557194 Sharp s 4.073306 Cyr Yi 2.902266 last 0.015322 47.325u 1.456s 0:48.23 101.1% 11246+419k 0+0io 0pf+0w === latin a 4.584374 Sharp s 0.065816 Cyr Yi 0.290468 last 4.698412 9.848u 0.046s 0:09.88 100.0% 11307+421k 0+0io 0pf+0w === latin a 0.015102 Sharp s 0.024983 Cyr Yi 0.030565 last 0.101628 0.463u 0.030s 0:00.43 113.9% 11499+428k 0+0io 0pf+0w MLton > ./unicode-case ; echo "===" ; ./unicode-if ; echo "===" ; ./unicode-if-opt latin a 0.00119 Sharp s 0.001167 Cyr Yi 0.001176 last 0.001172 === latin a 0.541467 Sharp s 0.024442 Cyr Yi 0.121234 last 0.537045 === latin a 0.013061 Sharp s 0.025635 Cyr Yi 0.154532 last 0.550286 > sml unicode-case.sml Standard ML of New Jersey v110.77 [built: Sun Jun 24 00:25:15 2018] [opening unicode-case.sml] [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [autoloading done] latin a 0.001608 Sharp s 0.00166 Cyr Yi 0.001546 last 0.001552 val fc = fn : word -> word list -> word list val runBench = fn : int -> string -> (unit -> 'a) -> unit - ^D > sml unicode-if.sml Standard ML of New Jersey v110.77 [built: Sun Jun 24 00:25:15 2018] [opening unicode-if.sml] [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [autoloading done] latin a 0.550017 Sharp s 0.02571 Cyr Yi 0.121336 last 0.548638 val fc = fn : word -> word list -> word list val runBench = fn : int -> string -> (unit -> 'a) -> unit - ^D > sml unicode-if-opt.sml Standard ML of New Jersey v110.77 [built: Sun Jun 24 00:25:15 2018] [opening unicode-if-opt.sml] [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [autoloading done] latin a 0.014573 Sharp s 0.027239 Cyr Yi 0.124949 last 0.557338 val fc = fn : word -> word list -> word list val runBench = fn : int -> string -> (unit -> 'a) -> unit - ^D _______________________________________________ polyml mailing list polyml@inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml