Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Merge branch 'issue_7_benchmark_node'
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
  • Loading branch information
mzsanford committed Apr 18, 2012
2 parents 82d9572 + f02e590 commit ce0ecba
Show file tree
Hide file tree
Showing 136 changed files with 69 additions and 19,193 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ libtool




# Ports (node) # Ports (node)
/ports/node/build ports/node/build
ports/node/node_modules


# Build artifacts # Build artifacts
*.o *.o
*.lo *.lo
*.la *.la
.libs .libs
6 changes: 3 additions & 3 deletions ports/node/.lock-wscript
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,8 @@
argv = ['/usr/local/bin/node-waf', 'configure'] argv = ['/Users/matt/.nvm/v0.4.7/bin/node-waf', 'configure', 'build']
blddir = '/Users/matt/src/github/cld/ports/node/build' blddir = '/Users/matt/src/github/cld/ports/node/build'
commands = {'dist': 0, 'configure': True, 'distcheck': 0, 'install': 0, 'build': 0, 'clean': 0, 'distclean': 0, 'check': 0, 'uninstall': 0} commands = {'dist': 0, 'configure': True, 'distcheck': 0, 'install': 0, 'build': True, 'clean': 0, 'distclean': 0, 'check': 0, 'uninstall': 0}
cwd = '/Users/matt/src/github/cld/ports/node' cwd = '/Users/matt/src/github/cld/ports/node'
environ = {'rvm_version': '1.9.2', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'rvm_path': '/Users/matt/.rvm', 'escape_flag': '1', 'LOGNAME': 'matt', 'USER': 'matt', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/Users/matt/.rvm/bin', 'PS2': '\xe2\x9e\x94', 'HOME': '/Users/matt', 'PS1': '\\u@laptop:\\w \xe2\x88\xb4 ', 'DISPLAY': '/tmp/launch-C68c3I/org.x:0', 'rvm_verbose_flag': '0', 'LANG': 'en_US.UTF-8', 'TERM': 'xterm-256color', 'SHELL': '/bin/bash', '_first': '0', 'VERSIONER_PYTHON_VERSION': '2.7', 'SHLVL': '1', '__array_start': '0', 'rvm_debug_flag': '0', 'ITERM_SESSION_ID': 'w0t0p0', '_': '/usr/local/bin/node-waf', 'rvm_reload_flag': '0', 'TERM_PROGRAM': 'iTerm.app', 'rvm_bin_path': '/Users/matt/.rvm/bin', 'rvm_prefix': '/Users/matt', 'rvm_dump_environment_flag': '0', 'SSH_AUTH_SOCK': '/tmp/launch-GExxjl/Listeners', 'rvm_trace_flag': '0', 'Apple_PubSub_Socket_Render': '/tmp/launch-xKDmKf/Render', 'ITERM_PROFILE': 'Default', 'rvm_clang_flag': '0', 'TMPDIR': '/var/folders/67/cvjc5q4j4q156ncpfsy84f7w0000gn/T/', '_second': '1', 'OLDPWD': '/Users/matt/src/github/cld/ports', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'PWD': '/Users/matt/src/github/cld/ports/node', 'COMMAND_MODE': 'unix2003'} environ = {'npm_package_author_url': 'http://mzsanford.com', 'rvm_version': '1.9.2', 'npm_config_searchopts': '', 'npm_config_group': '20', 'RUBY_VERSION': 'ruby-1.9.2-p290', 'npm_config_browser': 'open', 'npm_package_repository_url': '', 'NVM_DIR': '/Users/matt/.nvm', 'npm_config_global': 'false', 'npm_config_color': 'true', 'DISPLAY': '/tmp/launch-H4wQ7T/org.x:0', 'TERM_PROGRAM': 'iTerm.app', 'LANG': 'en_US.UTF-8', 'npm_config_pre': 'false', 'SHELL': '/bin/bash', '_first': '0', 'npm_config_save': 'false', 'npm_config_registry': 'http://registry.npmjs.org/', 'npm_config_unicode': 'true', 'npm_config_production': 'false', 'NVM_BIN': '/Users/matt/.nvm/v0.4.7/bin', 'NVM_PATH': '/Users/matt/.nvm/v0.4.7/lib/node', 'npm_config_message': '%s', 'npm_config_always_auth': 'false', 'TMPDIR': '/var/folders/67/cvjc5q4j4q156ncpfsy84f7w0000gn/T/', 'MANPATH': '/Users/matt/.nvm/v0.4.7/share/man:', 'npm_config_searchexclude': 'null', 'npm_config_loglevel': 'info', 'npm_config_logfd': '2', 'ARCHFLAGS': '-arch x86_64', 'npm_package_engines_node': '~0.6', 'npm_config_argv': '"install" "-d"', 'npm_package_devDependencies_nodeunit': '>=0.6.2', 'rvm_prefix': '/Users/matt', 'npm_package_scripts_preinstall': 'node-waf clean || true; node-waf configure build', 'npm_package_devDependencies_benchmark': '>=0.3.0', 'npm_config_strict_ssl': 'true', 'IRBRC': '/Users/matt/.rvm/rubies/ruby-1.9.2-p290/.irbrc', 'npm_config_tar': 'tar', 'MY_RUBY_HOME': '/Users/matt/.rvm/rubies/ruby-1.9.2-p290', 'npm_package_dependencies_benchmark': '>=0.3.0', 'npm_config_init_version': '0.0.0', 'npm_lifecycle_event': 'preinstall', 'npm_config_rollback': 'true', 'npm_package_version': '0.1.0', 'npm_config_init_author_name': '', 'npm_config_link': 'false', 'npm_config_globalignorefile': '/Users/matt/.nvm/v0.4.7/etc/npmignore', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'npm_config_yes': 'null', 'npm_config_npaturl': 'http://npat.npmjs.org/', 'npm_config_usage': 'false', 'npm_package_description': 'Google Chrome Compact Language Detector', 'npm_config_shell': '/bin/bash', 'npm_config_force': 'false', 'LOGNAME': 'matt', 'npm_config_ignore': '', 'GEM_HOME': '/Users/matt/.rvm/gems/ruby-1.9.2-p290', '_': '/Users/matt/.nvm/v0.4.7/bin/node-waf', 'npm_config_tmp': '/var/folders/67/cvjc5q4j4q156ncpfsy84f7w0000gn/T', 'npm_config_ca': '"-----BEGIN CERTIFICATE-----\\nMIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC\\nVVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwNucG0x\\nIjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w\\nbUNBMRcwFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y\\nMTA5MDIwMTQ3MTdaMIGHMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV\\nBAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTEiMCAGA1UECxMZbnBtIENlcnRpZmlj\\nYXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqhkiG9w0BCQEWCGlA\\naXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9GE\\nOgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz\\nGn2U181KGprGKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl\\ny0HdbT5m1ZGh6SJz3ZqxavhHLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbC\\nl7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQpCv8FfxsYE7dhf/bmWTEupBkv\\nyNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB1YhQKJtvUrl\\nZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Op\\n-----END CERTIFICATE-----"', 'npm_config_globalconfig': '/Users/matt/.nvm/v0.4.7/etc/npmrc', 'npm_package_name': 'cld', 'npm_config_userconfig': '/Users/matt/.npmrc', 'npm_config_bin_publish': 'false', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'npm_config_parseable': 'false', 'rvm_path': '/Users/matt/.rvm', 'npm_config_dev': 'false', 'escape_flag': '1', 'npm_config_rebuild_bundle': 'true', 'npm_config_userignorefile': '/Users/matt/.npmignore', 'npm_config_username': '', 'USER': 'matt', 'HOME': '/Users/matt', 'PATH': '/Users/matt/src/github/cld/ports/node/node_modules/.bin:/Users/matt/.nvm/v0.4.7/bin:/Users/matt/.rvm/gems/ruby-1.9.2-p290/bin:/Users/matt/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/matt/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/matt/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin', 'npm_config_gzipbin': 'gzip', 'npm_package_author_name': 'Matt Sanford', 'TERM': 'xterm-256color', 'npm_config_unsafe_perm': 'true', 'npm_package_scripts_test': './test.js', 'npm_config_onload_script': 'null', 'VERSIONER_PYTHON_VERSION': '2.7', 'SHLVL': '2', '__array_start': '0', 'npm_config_init_author_url': '', 'npm_config_bindist': '0.4-ares1.7.4-ev4.4-openssl0.9.8r-v83.1.8.10-darwin-11.2.0', 'rvm_dump_environment_flag': '0', 'ITERM_SESSION_ID': 'w0t0p0', 'npm_config_cache': '/Users/matt/.npm', 'EDITOR': 'vi', 'rvm_reload_flag': '0', 'rvm_verbose_flag': '0', 'GEM_PATH': '/Users/matt/.rvm/gems/ruby-1.9.2-p290:/Users/matt/.rvm/gems/ruby-1.9.2-p290@global', 'rvm_bin_path': '/Users/matt/.rvm/bin', 'npm_config_viewer': 'man', 'SSH_AUTH_SOCK': '/tmp/launch-dRx9Cx/Listeners', 'npm_config_proxy': 'null', 'npm_config_showlevel': '1', 'rvm_debug_flag': '0', 'npm_config_depth': 'Infinity', 'npm_config_logprefix': 'true', 'npm_config_umask': '022', '_second': '1', 'npm_config_long': 'false', 'Apple_PubSub_Socket_Render': '/tmp/launch-4WB7f8/Render', 'npm_config_editor': 'vi', 'npm_config_user': '501', 'ITERM_PROFILE': 'Default', 'npm_config_https_proxy': 'null', 'rvm_clang_flag': '0', 'npm_config_prefix': '/Users/matt/.nvm/v0.4.7', 'npm_config_node_version': '0.4.7', 'npm_config_init_author_email': '', 'npm_config_npat': 'false', 'npm_config_outfd': '1', 'npm_config_version': 'false', 'rvm_trace_flag': '0', 'npm_package_author_email': 'matt@mzsanford.com', 'npm_lifecycle_script': 'node-waf clean || true; node-waf configure build', 'PWD': '/Users/matt/src/github/cld/ports/node', 'npm_config_description': 'true', 'npm_config_tag': 'latest', 'npm_package_dependencies_nodeunit': '>=0.6.2', 'COMMAND_MODE': 'unix2003'}
files = [] files = []
hash = 0 hash = 0
options = {'compile_targets': None, 'force': False, 'verbose': 0, 'nocache': False, 'progress_bar': 0, 'destdir': '', 'keep': False, 'zones': '', 'blddir': '', 'prefix': '/usr/local/', 'jobs': 4, 'srcdir': '', 'check_cxx_compiler': 'g++'} options = {'compile_targets': None, 'force': False, 'verbose': 0, 'nocache': False, 'progress_bar': 0, 'destdir': '', 'keep': False, 'zones': '', 'blddir': '', 'prefix': '/usr/local/', 'jobs': 4, 'srcdir': '', 'check_cxx_compiler': 'g++'}
Expand Down
35 changes: 35 additions & 0 deletions ports/node/benchmark.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,35 @@

var Benchmark = require("benchmark");
var suite = new Benchmark.Suite;


var path = require('path');
var LanguageDetector;
if (path.existsSync("./build/Release")) {
LanguageDetector = require("./build/Release/languagedetector.node").LanguageDetector;
} else {
LanguageDetector = require("./build/default/languagedetector.node").LanguageDetector;
}
var detector = new LanguageDetector();

// add tests
suite.add('Create#test', function() {
new LanguageDetector().detectSync("This is my sample text")
})
.add('Reuse#test', function() {
detector.detectSync("This is my sample text")
})
.add('ReuseAsync#test', function() {
detector.detect("This is my sample text", function(res) {
// NO-OP
});
})
// add listeners
.on('cycle', function(event, bench) {
console.log(String(bench));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
// run async
.run({ 'async': true });
Binary file removed ports/node/build/.wafpickle-7
Binary file not shown.
2 changes: 0 additions & 2 deletions ports/node/build/c4che/build.config.py

This file was deleted.

44 changes: 0 additions & 44 deletions ports/node/build/config.log

This file was deleted.

17 changes: 15 additions & 2 deletions ports/node/languagedetector.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
using namespace node; using namespace node;
using namespace v8; using namespace v8;


#define CALLBACK_TYPE int

#if (NODE_MAJOR_VERSION == 0) && (NODE_MINOR_VERSION == 6)
#define NODE_0_6_X
#define CALLBACK_TYPE void
#else
#define CALLBACK_TYPE int
#endif

class LanguageDetector: ObjectWrap class LanguageDetector: ObjectWrap
{ {
private: private:
Expand Down Expand Up @@ -205,7 +214,7 @@ class LanguageDetector: ObjectWrap
} }


// Background thread: The asynch portion // Background thread: The asynch portion
static void EIO_Detect(eio_req *req) static CALLBACK_TYPE EIO_Detect(eio_req *req)
{ {
language_detect_baton_t *baton = static_cast<language_detect_baton_t *>(req->data); language_detect_baton_t *baton = static_cast<language_detect_baton_t *>(req->data);
baton->result = new language_detect_result_t(); baton->result = new language_detect_result_t();
Expand Down Expand Up @@ -238,7 +247,11 @@ class LanguageDetector: ObjectWrap
&baton->result->reliable); &baton->result->reliable);


std::string lang_str(LanguageCode(lang)); std::string lang_str(LanguageCode(lang));
baton->result->language_code = lang_str; baton->result->language_code = lang_str;

#ifndef NODE_0_6_X
return 0;
#endif
} }


// Main thread: The return portion after the async portion is completed // Main thread: The return portion after the async portion is completed
Expand Down
1 change: 0 additions & 1 deletion ports/node/node_modules/.bin/nodeunit

This file was deleted.

5 changes: 0 additions & 5 deletions ports/node/node_modules/nodeunit/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions ports/node/node_modules/nodeunit/.npmignore

This file was deleted.

68 changes: 0 additions & 68 deletions ports/node/node_modules/nodeunit/CONTRIBUTORS.md

This file was deleted.

19 changes: 0 additions & 19 deletions ports/node/node_modules/nodeunit/LICENSE

This file was deleted.

Loading

0 comments on commit ce0ecba

Please sign in to comment.