[Pkg-javascript-commits] [node-iconv-lite] 33/83: Updated performance benchmark.
matthew pideil
mpideil-guest at moszumanska.debian.org
Tue Apr 1 19:56:48 UTC 2014
This is an automated email from the git hooks/post-receive script.
mpideil-guest pushed a commit to branch master
in repository node-iconv-lite.
commit 29c3ea8507c83594e9d24c9e6d2922e4760d9ed0
Author: Alexander Shtuchkin <ashtuchkin at gmail.com>
Date: Mon May 7 23:04:07 2012 +0400
Updated performance benchmark.
---
README.md | 14 +++++++++-----
test/perfomance.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index b226161..fc6c1b6 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,10 @@ iconv-lite - pure javascript character encoding conversion
## Features
+* Pure javascript. Doesn't need native code compilation.
* Easy API.
-* Works on Windows and in sandboxed environments like [Cloud9](http://c9.io) (doesn't need native code compilation).
-* Faster than iconv (see below for performance comparison).
+* Works on Windows and in sandboxed environments like [Cloud9](http://c9.io).
+* Encoding is faster than node-iconv, decoding slightly slower (see below for performance comparison).
## Usage
@@ -33,12 +34,12 @@ Not supported yet: Big5, EUC family, Shift_JIS.
## Encoding/decoding speed
-Comparison with iconv module (1000 times 256kb, on Core i5/2.5 GHz).
+Comparison with node-iconv module (1000 times 256kb, on Core i5/2.5 GHz, Node v0.6.17).
operation iconv iconv-lite (this module)
----------------------------------------------------------
- encode('win1251') 19.57 mb/s 49.04 mb/s
- decode('win1251') 16.39 mb/s 24.11 mb/s
+ encode('win1251') ~30 Mb/s ~45 Mb/s
+ decode('win1251') ~33 Mb/s ~27 Mb/s
## Notes
@@ -49,6 +50,9 @@ Untranslatable characters are set to � or ?. No transliteration is currently s
npm install --dev iconv-lite
vows
+
+ # To view performance:
+ node test/performance.js
## TODO
diff --git a/test/perfomance.js b/test/perfomance.js
new file mode 100644
index 0000000..7d75d1f
--- /dev/null
+++ b/test/perfomance.js
@@ -0,0 +1,57 @@
+
+var iconv = require('iconv');
+var iconv_lite = require("../index");
+
+var encoding = "windows-1251";
+var convertTimes = 1000;
+
+// Test encoding.
+var str = "This is a test string 32 chars..";
+for (var i = 0; i < 13; i++)
+ str = str + str;
+
+console.log("\nEncoding "+str.length+" chars "+convertTimes+" times:");
+
+var start = Date.now();
+var converter = new iconv.Iconv("utf8", encoding);
+for (var i = 0; i < convertTimes; i++) {
+ var b = converter.convert(str);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*str.length/duration/1024;
+
+console.log("iconv: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+var start = Date.now();
+for (var i = 0; i < convertTimes; i++) {
+ var b = iconv_lite.encode(str, encoding);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*str.length/duration/1024;
+
+console.log("iconv-lite: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+
+// Test decoding.
+var buf = iconv_lite.encode(str, encoding);
+console.log("\nDecoding "+buf.length+" bytes "+convertTimes+" times:");
+
+var start = Date.now();
+var converter = new iconv.Iconv(encoding, "utf8");
+for (var i = 0; i < convertTimes; i++) {
+ var s = converter.convert(buf).toString();
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*buf.length/duration/1024;
+
+console.log("iconv: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
+var start = Date.now();
+for (var i = 0; i < convertTimes; i++) {
+ var s = iconv_lite.decode(buf, encoding);
+}
+var duration = Date.now() - start;
+var mbs = convertTimes*buf.length/duration/1024;
+
+console.log("iconv-lite: "+duration+"ms, "+mbs.toFixed(2)+" Mb/s.");
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iconv-lite.git
More information about the Pkg-javascript-commits
mailing list