https://github.com/SamSaffron/fast_blank
https://github.com/SamSaffron/fast_blank
Keywords from Contributors
rubygems activerecord activejob mvc rspec rack nokogiri dsl minitest sinatra
Last synced: about 8 hours ago
JSON representation
Repository metadata
- Host: GitHub
- URL: https://github.com/SamSaffron/fast_blank
- Owner: SamSaffron
- License: mit
- Created: 2013-03-29T02:04:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-21T11:34:57.000Z (almost 2 years ago)
- Last Synced: 2025-11-27T17:13:20.862Z (13 days ago)
- Language: Ruby
- Size: 60.5 KB
- Stars: 617
- Watchers: 9
- Forks: 36
- Open Issues: 3
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
README.md
String#blank? Ruby Extension
fast_blank is a simple C extension which provides a fast implementation of Active Support's String#blank? method.
How do you use it?
require 'fast_blank'
or add it to your Bundler Gemfile
gem 'fast_blank'
How fast is "Fast"?
About 1.2–20x faster than Active Support on my machine (your mileage my vary, depends on string length):
$ bundle exec ./benchmark
================== Test String Length: 0 ==================
Calculating -------------------------------------
Fast Blank 225.251k i/100ms
Fast ActiveSupport 225.676k i/100ms
Slow Blank 110.934k i/100ms
New Slow Blank 221.792k i/100ms
-------------------------------------------------
Fast Blank 29.673M (± 2.7%) i/s - 148.215M
Fast ActiveSupport 28.249M (± 3.5%) i/s - 141.048M
Slow Blank 2.158M (± 3.3%) i/s - 10.872M
New Slow Blank 23.558M (± 3.2%) i/s - 117.772M
Comparison:
Fast Blank: 29673200.1 i/s
Fast ActiveSupport: 28248894.5 i/s - 1.05x slower
New Slow Blank: 23557900.0 i/s - 1.26x slower
Slow Blank: 2157787.7 i/s - 13.75x slower
================== Test String Length: 6 ==================
Calculating -------------------------------------
Fast Blank 201.185k i/100ms
Fast ActiveSupport 205.076k i/100ms
Slow Blank 102.061k i/100ms
New Slow Blank 123.087k i/100ms
-------------------------------------------------
Fast Blank 13.894M (± 2.3%) i/s - 69.409M
Fast ActiveSupport 14.627M (± 3.5%) i/s - 73.212M
Slow Blank 1.943M (± 2.3%) i/s - 9.798M
New Slow Blank 2.796M (± 1.8%) i/s - 14.032M
Comparison:
Fast ActiveSupport: 14627063.7 i/s
Fast Blank: 13893631.2 i/s - 1.05x slower
New Slow Blank: 2795783.3 i/s - 5.23x slower
Slow Blank: 1943025.9 i/s - 7.53x slower
================== Test String Length: 14 ==================
Calculating -------------------------------------
Fast Blank 220.004k i/100ms
Fast ActiveSupport 219.716k i/100ms
Slow Blank 147.399k i/100ms
New Slow Blank 106.651k i/100ms
-------------------------------------------------
Fast Blank 24.949M (± 3.0%) i/s - 124.742M
Fast ActiveSupport 24.491M (± 3.3%) i/s - 122.382M
Slow Blank 4.292M (± 1.6%) i/s - 21.520M
New Slow Blank 2.115M (± 2.4%) i/s - 10.665M
Comparison:
Fast Blank: 24948558.8 i/s
Fast ActiveSupport: 24491245.1 i/s - 1.02x slower
Slow Blank: 4292490.5 i/s - 5.81x slower
New Slow Blank: 2115097.6 i/s - 11.80x slower
================== Test String Length: 24 ==================
Calculating -------------------------------------
Fast Blank 206.555k i/100ms
Fast ActiveSupport 208.513k i/100ms
Slow Blank 137.733k i/100ms
New Slow Blank 101.215k i/100ms
-------------------------------------------------
Fast Blank 16.761M (± 2.7%) i/s - 83.861M
Fast ActiveSupport 17.710M (± 3.2%) i/s - 88.618M
Slow Blank 3.744M (± 2.0%) i/s - 18.732M
New Slow Blank 1.962M (± 2.7%) i/s - 9.818M
Comparison:
Fast ActiveSupport: 17709936.5 i/s
Fast Blank: 16760839.7 i/s - 1.06x slower
Slow Blank: 3744048.4 i/s - 4.73x slower
New Slow Blank: 1961831.1 i/s - 9.03x slower
================== Test String Length: 136 ==================
Calculating -------------------------------------
Fast Blank 201.772k i/100ms
Fast ActiveSupport 189.120k i/100ms
Slow Blank 129.439k i/100ms
New Slow Blank 90.677k i/100ms
-------------------------------------------------
Fast Blank 16.718M (± 2.8%) i/s - 83.534M
Fast ActiveSupport 17.617M (± 3.6%) i/s - 87.941M
Slow Blank 3.725M (± 3.0%) i/s - 18.639M
New Slow Blank 1.940M (± 4.8%) i/s - 9.702M
Comparison:
Fast ActiveSupport: 17616782.1 i/s
Fast Blank: 16718307.8 i/s - 1.05x slower
Slow Blank: 3725097.6 i/s - 4.73x slower
New Slow Blank: 1940271.2 i/s - 9.08x slower
Additionally, this gem allocates no strings during the test, making it less of a GC burden.
Compatibility note:
fast_blank supports MRI Ruby 1.9.3, 2.0, 2.1, and 2.2, as well as Rubinius 2.x. Earlier versions of MRI are untested.
fast_blank implements String#blank? as MRI would have implemented it, meaning it has 100% parity with String#strip.length == 0.
Active Support's version also considers Unicode spaces. For example, "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000".blank? is true in Active Support even though fast_blank would treat it as not blank. Therefore, fast_blank also provides blank_as? which is a 100%-compatible Active Support blank? replacement.
Credits
- Author: Sam Saffron (sam.saffron@gmail.com)
- https://github.com/SamSaffron/fast_blank
- License: MIT
- Gem template based on CodeMonkeySteve/fast_xor
Change log:
1.0.1:
- Minor, avoid warnings if redefining blank?
1.0.0:
0.0.2:
Owner metadata
- Name: Sam
- Login: SamSaffron
- Email:
- Kind: user
- Description:
- Website: http://www.samsaffron.com
- Location: Sydney, Australia
- Twitter:
- Company: @discourse
- Icon url: https://avatars.githubusercontent.com/u/5213?v=4
- Repositories: 147
- Last ynced at: 2023-04-09T06:51:56.015Z
- Profile URL: https://github.com/SamSaffron
GitHub Events
Total
- Watch event: 9
- Issue comment event: 3
- Pull request event: 1
- Fork event: 3
Last Year
- Watch event: 8
- Issue comment event: 3
- Pull request event: 1
- Fork event: 3
Committers metadata
Last synced: 2 days ago
Total Commits: 62
Total Committers: 14
Avg Commits per committer: 4.429
Development Distribution Score (DDS): 0.532
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Sam | s****n@g****m | 29 |
| T.J. Schuck | tj@g****m | 9 |
| Peter M. Goldstein | p****n@g****m | 5 |
| Aman Gupta | a****n@t****t | 4 |
| Gourav Tiwari | g****1@g****m | 3 |
| Thomas E. Enebo | t****o@g****m | 2 |
| Orien Madgwick | 4****n | 2 |
| Nobuyoshi Nakada | n****u@r****g | 2 |
| Steve Klabnik | s****e@s****m | 1 |
| Simon Perepelitsa | s****a@s****n | 1 |
| Nicholas Rutherford | n****d@g****m | 1 |
| Igor Victor | g****a@y****u | 1 |
| Charles Oliver Nutter | h****s@h****m | 1 |
| Alain Pilon | a****n@g****m | 1 |
Committer domains:
- headius.com: 1
- yandex.ru: 1
- sema.in: 1
- steveklabnik.com: 1
- ruby-lang.org: 1
- tmm1.net: 1
- getharvest.com: 1
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 7
Total pull requests: 26
Average time to close issues: 7 months
Average time to close pull requests: 3 months
Total issue authors: 7
Total pull request authors: 17
Average comments per issue: 4.71
Average comments per pull request: 2.58
Merged pull request: 21
Bot issues: 0
Bot pull requests: 1
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- envygeeks (1)
- zw963 (1)
- nirvdrum (1)
- tibbon (1)
- PikachuEXE (1)
- OpenCoderX (1)
- pschambacher (1)
Top Pull Request Authors
- tjschuck (5)
- petergoldstein (4)
- orien (3)
- nobu (2)
- ken3ypa (1)
- akitaonrails (1)
- dependabot[bot] (1)
- steveklabnik (1)
- gouravtiwari (1)
- headius (1)
- AlainPilon (1)
- nruth (1)
- semaperepelitsa (1)
- gogainda (1)
- enebo (1)
Top Issue Labels
Top Pull Request Labels
- dependencies (1)
Package metadata
- Total packages: 4
-
Total downloads:
- rubygems: 120,201,941 total
- Total docker downloads: 936,074,938
- Total dependent packages: 23 (may contain duplicates)
- Total dependent repositories: 7,762 (may contain duplicates)
- Total versions: 12
- Total maintainers: 2
gem.coop: fast_blank
Provides a C-optimized method for determining if a string is blank
- Homepage: https://github.com/SamSaffron/fast_blank
- Documentation: http://www.rubydoc.info/gems/fast_blank/
- Licenses: MIT
- Latest release: 1.0.1 (published over 4 years ago)
- Last Synced: 2025-12-08T19:02:03.532Z (1 day ago)
- Versions: 5
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 60,103,611 Total
- Docker Downloads: 468,037,469
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.168%
- Docker downloads count: 0.222%
- Downloads: 0.45%
- Maintainers (2)
rubygems.org: fast_blank
Provides a C-optimized method for determining if a string is blank
- Homepage: https://github.com/SamSaffron/fast_blank
- Documentation: http://www.rubydoc.info/gems/fast_blank/
- Licenses: MIT
- Latest release: 1.0.1 (published over 4 years ago)
- Last Synced: 2025-12-08T11:34:25.025Z (2 days ago)
- Versions: 5
- Dependent Packages: 23
- Dependent Repositories: 7,762
- Downloads: 60,098,330 Total
- Docker Downloads: 468,037,469
-
Rankings:
- Docker downloads count: 0.284%
- Dependent repos count: 0.366%
- Downloads: 0.457%
- Dependent packages count: 1.022%
- Average: 1.49%
- Stargazers count: 2.317%
- Forks count: 4.493%
- Maintainers (2)
proxy.golang.org: github.com/SamSaffron/fast_blank
- Homepage:
- Documentation: https://pkg.go.dev/github.com/SamSaffron/fast_blank#section-documentation
- Licenses: mit
- Latest release: v1.0.1 (published over 4 years ago)
- Last Synced: 2025-12-06T23:01:21.954Z (3 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.999%
- Average: 8.173%
- Dependent repos count: 9.346%
proxy.golang.org: github.com/samsaffron/fast_blank
- Homepage:
- Documentation: https://pkg.go.dev/github.com/samsaffron/fast_blank#section-documentation
- Licenses: mit
- Latest release: v1.0.1 (published over 4 years ago)
- Last Synced: 2025-12-06T23:01:20.849Z (3 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.999%
- Average: 8.173%
- Dependent repos count: 9.346%
Dependencies
- guard-rspec >= 0
- rake >= 0
- rubysl ~> 2.0
- benchmark-ips >= 0 development
- rake-compiler >= 0 development
- rspec >= 0 development
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 29.846800806695434