Skip to content

JesseBuesking/ruby_omnomnum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OmNomNum

Wrapper for the OmNomNum c project, which implements most of the logic from numerizer.

Gem Version

Install

gem install omnomnum

Usage

require 'omnomnum'

OmNomNum.normalize('first')
=> "1st"
OmNomNum.normalize('second')
=> "second"
OmNomNum.normalize('second', parse_second: true)
=> "2nd"

Benchmarks

Memory

Library Bytes at exit Total # of Allocations Total Frees Total # of Bytes Allocated Savings
Numerizer1 2,746,272 59,243 35,161 11,055,638 -
Numerizer2 3,719,364 10,852,981 10,821,658 1,115,915,077 -
Numerizer3 973,092 10,793,738 10,786,497 1,104,859,439
OmNomNum1 2,657,613 57,967 34,681 10,797,999 -
OmNomNum2 2,659,473 62,006 38,700 10,839,010 -
OmNomNum3 1,860 4,039 4,019 41,011 25,000+×

1: loads the library and does nothing else
2: runs the string "two hundred" 2,000 times
3: difference between 1 and 2

Note: Benchmark done using valgrind. valgrind ruby -w Ilib test/memory_test_*.rb

CPU

Library Iterations per second Speedup
Numerizer 323.271
OmNomNum 2.516M 7,750+×

Notes

The OmNomNum actually has two methods: one that returns a normalized string, and one that returns a list containing the locations of the numbers in the string and their values. ruby_omnomnum currently only supports the first function, but the second could eventually be exposed.

About

Gobbles up numbers in strings.

Resources

License

Stars

3 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors