Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aheckmann/node-gmp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: postwait/node-gmp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 15 commits
  • 8 files changed
  • 1 contributor

Commits on Mar 13, 2011

  1. Copy the full SHA
    1c3e7c0 View commit details
  2. Add float support and abort subversion. Optionally use the

    sane approach (patch submitted to libgmp-devel list)
    postwait committed Mar 13, 2011
    Copy the full SHA
    c35ca6b View commit details
  3. Copy the full SHA
    6db416b View commit details
  4. bail if code hacking doesn't work -- which is most cases unless you w…

    …ere relatively insane compiling it all
    postwait committed Mar 13, 2011
    Copy the full SHA
    cd4586b View commit details

Commits on Mar 16, 2011

  1. Do this the most evil way possible. This appear to work in my tests.

    libgmp fellas are being unfortunately uncooperative in improving their
    software, so it make sense to have a tenable solution without them.
    
    This can and will badly malfunction at some point, I'm not sure I ever
    want to run this in production -- time will tell.
    
    This uses signals catching the SIGABRT and SIGFPE (the two raised in
    libgmp) and siglongjmps out of them.  In single threaded programs the
    SIGFPE should be entirely safe, the SIGABRT is a bit more risky.  We
    limit the siglongjmp to when we know we've called into libgmp.
    
    And I will end this with a parting note: libgmp can suck it.
    postwait committed Mar 16, 2011
    Copy the full SHA
    0f3a1c3 View commit details
  2. Copy the full SHA
    bce9618 View commit details

Commits on Mar 17, 2011

  1. Copy the full SHA
    bd56516 View commit details
  2. updated info

    postwait committed Mar 17, 2011
    Copy the full SHA
    ccd509b View commit details
  3. rename README

    postwait committed Mar 17, 2011
    Copy the full SHA
    2650f9e View commit details
  4. ## for markdown

    postwait committed Mar 17, 2011
    Copy the full SHA
    ea73804 View commit details

Commits on Mar 19, 2011

  1. Copy the full SHA
    f560a83 View commit details
  2. make the benchmark work

    postwait committed Mar 19, 2011
    Copy the full SHA
    0863709 View commit details
  3. cmp and test

    postwait committed Mar 19, 2011
    Copy the full SHA
    3061009 View commit details
  4. Copy the full SHA
    b3226d3 View commit details
  5. toValue for ints

    postwait committed Mar 19, 2011
    Copy the full SHA
    89041ba View commit details
Showing with 819 additions and 66 deletions.
  1. +0 −12 Makefile
  2. +0 −17 README
  3. +30 −0 README.md
  4. +5 −5 benchmarks/index.js
  5. +698 −27 node_gmp.cc
  6. +43 −0 node_gmp.h
  7. +34 −1 test/index.js
  8. +9 −4 wscript
12 changes: 0 additions & 12 deletions Makefile

This file was deleted.

17 changes: 0 additions & 17 deletions README

This file was deleted.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# node-gmp

## synopsis

node-gmp wraps the libgmp library. This library has some poor practices
when it comes to erro handling, so much trickery and deception is used to
make this stable under node. Trickery includes: replacement allocators,
replacement of jumps to abort() in instruction code and finally using
sigsetjmp and siglongjmp to emulate try/throw a across C and signals in a
more stable fashion.

The rest of gmp is just code.

var gmp = require('gmp')
var i = gmp.Int("123412341234123412341234123412341234");
i.div("2").toString() // "61706170617061706170617061706170617"
var f = gmp.Float("1234123412341234.123412341234", 1024).div("1.337");
f.toString().replace(/(\.\d{10}).*$/, "$1") // "923054160315059.17981476530867"
var r = gmp.Rational("22/7");
r.toString() // "3.142857142857143"

## requirements

* http://gmplib.org/ -- built with c++ enabled ( ./configure --enable-cxx )


## installation

# (useful environment variables: CXXFLAGS LINKFLAGS)
$ node-waf configure build
10 changes: 5 additions & 5 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

var gmp = require('./build/default/gmp');
var gmp = require('../build/default/gmp');

var a = "23450745058237458237438124381247381327401278039423904183123785901234679435237852037045375237485072304728904023748502374580723804572803745802374723098234509187142";
var b = "90894587590237850247890451273126743687548782309875623443738065740178101237431274810018971234126789867123769146910981289658964389538365892375427436672345780686388";
var a = new gmp.Int("23450745058237458237438124381247381327401278039423904183123785901234679435237852037045375237485072304728904023748502374580723804572803745802374723098234509187142");
var b = new gmp.Int("90894587590237850247890451273126743687548782309875623443738065740178101237431274810018971234126789867123769146910981289658964389538365892375427436672345780686388");


var num = 1000000;
var num = 100000;
var start = Date.now();
for (var i = 0; i < num; ++i){
gmp.mul(a,b);
new gmp.Int(1).mul(a).mul(b);
}
var seconds = (Date.now()-start)/1000;
var opssec = num / seconds;
Loading