Skip to content

Releases: coip/moneypenny

v0.0.2

22 Feb 23:00
Compare
Choose a tag to compare
incorporate sub & mul operations

basis

31 Mar 19:41
Compare
Choose a tag to compare
basis Pre-release
Pre-release

this release serves to mark an ~alpha point of package stability and establishing ~acceptance guidelines.

package money provides:

  • type money.Money decimal.Decimal
  • type money.Pennies int64

money.Money elevators:

grep -oe "^func From.*Money" *
money.go:func FromString(m string) Money
money.go:func Fromf32(m float32)   Money
money.go:func Fromf64(m float64)   Money
money.go:func Fromi(m int)         Money
money.go:func Fromi64(m int64)     Money

money.Pennies plumbing:

func (p Pennies) ToMoney() Money
func (p Pennies) i64()     int64

  unwrapped operator:
func (p1 Pennies) Add(p2 Pennies)   Pennies //much faster than Money add() at the moment

For me at this moment, acceptance requires:

  • unit tests for func() operation validation
  • benchmarks: coverage: 100.0% of statements
  • tests: coverage: 100.0% of statements

benchmarks seem germane here: establishing qualitative metrics on the performance of pkg money as input for decision making going forward.

for the first production-ready release, I'd like to improve pkg money from the callers perspective.

one detail that needs addressing is error handling on money.go: FromString()
also need to implement various operators at this point...

view project v0.0.2 for a living-document reference on what's more-or-less formally been/being worked into the requirements.

State of the Benchmark*s:

generated with slightly refactored code using: grep -h -A1 'b.N\|func B' * | sed "s/^[ \t]*//" | sed 's/^.*for.*{[ ]*/_benchmark call:_/g' | sed -E 's/(.*):=/with \1as/g' | sed 's/^func/\n---\n#### func/g' | sed 's/^with/ with/g' | sed '/--/d' | tr -d '{'

func BenchmarkFromString10(b *testing.B)

benchmark call:
FromString("10")

func BenchmarkFromString10DollarSign(b *testing.B)

benchmark call:
FromString("$10")

func BenchmarkFromString10DollarSignNeg(b *testing.B)

benchmark call:
FromString("$-10")

func BenchmarkFromString1000(b *testing.B)

benchmark call:
FromString("1000")

func BenchmarkFromString10Bucks(b *testing.B)

benchmark call:
FromString("10.00")

func BenchmarkFromStringInvalid(b *testing.B)

benchmark call:
FromString("coip")

func BenchmarkFromi100(b *testing.B)

benchmark call:
Fromi(100)

func BenchmarkFromi1000(b *testing.B)

benchmark call:
Fromi(1000)

func BenchmarkFromiMaxInt32(b *testing.B)

benchmark call:
Fromi(2147483647)

func BenchmarkFromiMinInt32(b *testing.B)

benchmark call:
Fromi(-2147483648)

func BenchmarkFromiMaxInt64(b *testing.B)

benchmark call:
Fromi64(9223372036854775807)

func BenchmarkFromiMinInt64(b *testing.B)

benchmark call:
Fromi64(-9223372036854775808)

func BenchmarkFromi10(b *testing.B)

benchmark call:
Fromi(10)

func BenchmarkFromi64_10(b *testing.B)

benchmark call:
Fromi64(10)

func BenchmarkFromf32_10(b *testing.B)

benchmark call:
Fromf32(10)

func BenchmarkFromf64_10(b *testing.B)

benchmark call:
Fromf64(10)

func BenchmarkFromf64_Max(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+308)

func BenchmarkFromf64_Max95(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+290)

func BenchmarkFromf64_Max80(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+240)

func BenchmarkFromf64_Max65(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+190)

func BenchmarkFromf64_Max50(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+140)

func BenchmarkFromf64_Max35(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+80)

func BenchmarkFromf64_Max10(b *testing.B)

benchmark call:
Fromf64(1.7976931348623157e+30)

func BenchmarkFromf64_MaxNeg(b *testing.B)

benchmark call:
Fromf64(-1.7976931348623157e+308)

func BenchmarkFromf64_Min(b *testing.B)

benchmark call:
Fromf64(4.940656458412465441765687928682213723651e-323)

func BenchmarkString(b *testing.B)

with m as Fromi(100)
benchmark call:
_ = m.String()

func BenchmarkFormatter(b *testing.B)

with m as Fromi(100)
benchmark call:
FormatAsMoney(m)

func BenchmarkStringNeg(b *testing.B)

with m as Fromi(-100)
benchmark call:
_ = m.String()

func BenchmarkFormatterNeg(b *testing.B)

with m as Fromi(-100)
benchmark call:
FormatAsMoney(m)

func BenchmarkMoneyEqMoney(b *testing.B)

with m, q as Fromi(1000), Fromf32(10.00)
benchmark call:
m.Eq(q)

func BenchmarkAddingPennyToPennies(b *testing.B)

with p1, p2 as Penny*10, Pennies(0)
benchmark call:
p1 = p1.Add(p2)

func BenchmarkAdding1MMPennyToPennies(b *testing.B)

with p1, p2 as Penny*1000000, Pennies(1000000)
benchmark call:
p1 = p1.Add(p2)

func BenchmarkAddingPenniesToMoney(b *testing.B)

with p, m as Penny, Fromi(0)
benchmark call:
m = m.Add(p.ToMoney())

func BenchmarkAddingPennyToMoney(b *testing.B)

with p, m as Penny, Fromi(0)
benchmark call:
m = m.AddP(p)

func BenchmarkAddingMoneyToPenniesAndPenny(b *testing.B)

with p, m as Penny, Fromi(100)
benchmark call:
p = p.Add(m.ToPennies())

func BenchmarkCastingAddingPenniesNative(b *testing.B)

with p, m as 1, 0
benchmark call:
m += p

func BenchmarkCastingAddingPenniesNativeExplicit(b *testing.B)

with p, m as int64(1), int64(0)
benchmark call:
m += p

func BenchmarkCastingPenniesToInt64(b *testing.B)

benchmark call:
Penny.i64()