Skip to content

Commit

Permalink
Merge branch 'master' into kardianos-decomposer
Browse files Browse the repository at this point in the history
  • Loading branch information
kardianos authored Apr 9, 2019
2 parents c4e47de + b4c50b8 commit 46c142e
Show file tree
Hide file tree
Showing 43 changed files with 867 additions and 1,035 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go

go:
- "1.10.x"
- "1.11.x"
- "1.12.x"
- master

cache:
Expand Down
53 changes: 0 additions & 53 deletions benchmarks/README.md

This file was deleted.

69 changes: 69 additions & 0 deletions benchmarks/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Package benchmarks implements benchmarking across decimal packages.
//
// General Notes
//
// 1. Times are measured in seconds, unless otherwise noted
// 2. Measured on a MacBook Pro, 2.9 GHz Intel Core i5, 8 GB 2133 MHz LPDDR3
// 3. Some benchmarks are adapted from www.bytereef.org/mpdecimal/benchmarks.html
//
// While the benchmarks aim to be as fair as possible, the packages have
// different feature sets and objects.
//
// For example, go-inf/inf[8] boasts the fastest overall runtime of any package,
// but does not fully implement the GDA specification: it lacks contexts,
// non-finite values (NaN, Inf, or ±0), conditions, etc.
//
// Further, programs like cockroachdb/apd[2] sacrifice speed to ensure strict
// compliance with the GDA spec.
//
// In general, package sthat cannot fully complete a challenge will be unranked.
// For example, the ``float64'' type cannot provide 19 or more digits of precision,
// so it's unranked in the Pi test. Similarly so with apmckinlay/dnum[3].
//
// Pi
//
// Go programs are tested with Go 1.12.2.
//
// Java benchmarks are separated into two categories, warm and cold. Warm
// benchmarks are run 10,000 times prior to benchmarking.
//
// | Program (version) | 9 digits | 19 digits | 38 digits | 100 digits | average |
// |--------------------------------------|----------|-----------|-----------|------------|---------|
// | go-inf/inf[8] | 0.241 | 0.537 | 1.12 | 3.01 | 1.227 |
// | ericlagergren/decimal[1] (mode Go) | 0.142 | 0.639 | 1.46 | 4.16 | 1.60 |
// | Python decimal[5] (Python 3.7.3) | 0.38 | 0.791 | 1.77 | 6.21 | 2.29 |
// | JDK BigDecimal[4] (Java 1.8, warm) | 0.156 | 0.717 | 1.957 | 7.252 | 2.52 |
// | ericlagergren/decimal[1] (mode GDA) | 0.204 | 0.953 | 2.37 | 8.40 | 2.98 |
// | JDK BigDecimal[4] (Java 1.8, cold) | 0.532 | 1.638 | 3.413 | 7.747 | 3.332 |
// | shopspring/decimal[7] decimal | 0.83 | 1.78 | 4.00 | 10.90 | 4.37 |
// | cockroachdb/apd[2] | 1.54 | 7.50 | 43.6 | 237.00 | 72.41 |
// | Python decimal[6] (Python 2.7.10) | 31.81 | 74.502 | 161.71 | 460.00 | 182.00 |
// | float64 | 0.125 | - | - | - | - |
// | double (C LLVM 10.0.1 -O3) | 0.0589 | - | - | - | - |
// | apmckinlay/dnum[3] | 0.078 | - | - | - | - |
// | float (Python 2.7.10, 3.7.3) | 0.0923 | - | - | - | - |
//
// Mandelbrot
//
// Go programs are tested with Go 1.9.?.
//
// | Program (version) | 9 digits | 16 digits | 19 digits | 34 digits | 38 digits | average |
// |--------------------------------------|----------|-----------|-----------|-----------|-----------|---------|
// | ericlagergren/decimal[1] (mode GDA) | 2.73 | 9.07 | 14.54 | 24.95 | 25.09 | 15.27 |
// | ericlagergren/decimal[1] (mode Go) | 2.73 | 9.70 | 15.02 | 26.13 | 26.62 | 16.04 |
// | float64 | 0.0034 | - | - | - | - | - |
//
// References
//
// Further information and references can be found at the links below.
//
// [1]: github.com/ericlagergren/decimal
// [2]: github.com/cockroachdb/apd
// [3]: github.com/apmckinlay/gsuneido/util/dnum
// [4]: docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html
// [5]: docs.python.org/3.6/library/decimal.html
// [6]: docs.python.org/2/library/decimal.html
// [7]: github.com/shopspring/decimal
// [8]: github.com/go-inf/inf
//
package benchmarks
4 changes: 1 addition & 3 deletions benchmarks/mandelbrot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (

const mbrotiters = 10000000

var (
two = decimal.New(2, 0)
)
var two = decimal.New(2, 0)

func BenchmarkMandelbrot_float64(b *testing.B) {
var lf float64
Expand Down
1 change: 0 additions & 1 deletion benchmarks/pi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func calcPiGDA(prec int) *decimal.Big {
ctx.Add(s, s, t)
}
return s.Round(prec)

}

func calcPi_apd(prec uint32) *apd.Decimal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(void) {
for (int j = 0; j < ROUNDS; ++j) {
ld = calcPifloat();
}
sum += (double)(clock() - start_clock)/(double)(CLOCKS_PER_SEC);
sum += (double)(clock() - start_clock) / (double)(CLOCKS_PER_SEC);
}
gd = ld;
printf("average: %f\n", sum / NITER);
Expand Down
11 changes: 11 additions & 0 deletions benchmarks/testdata/java/java.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String... args) {
throw new IllegalArgumentException("bad argument " + args);
}

for (int i = 0; i < 10000; ++i) {
for (int i = 0; i < 0; ++i) {
r = fn.apply(new MathContext(precs[i % precs.length]));
}

Expand Down
File renamed without changes.
Loading

0 comments on commit 46c142e

Please sign in to comment.