25 Apr '16, 7am

~3.5x speedup of String#blank? for empty strings · rails/[email protected] · GitHub: ~3.5x speedup of… https://t.co/UdDXxvdbLZ

See the rationale in the comment in this patch. To benchmark this I ran a number of variations, ultimately narrowing to require 'benchmark/ips' str = '' regexp = /\A[[:space:]]*\z/ Benchmark.ips do |x| x.report('regexp') { regexp === str } x.report('empty') { str.empty? || regexp === str } x.compare! end This benchmark has consistently reported speedups around 3.5x: Calculating ------------------------------------- regexp 69.197k i/100ms empty 115.468k i/100ms ------------------------------------------------- regexp 2. 6.3%) i/s - 13.839M empty 9. 8.8%) i/s - 47.804M Comparison: empty: 9642607.6 i/s regexp: 2768351.9 i/s - 3.48x slower Sometimes even reaching 4x. Running the same bechmark on strings of 10 or 100 characters (with whitespace or present) has shown a slowdown of just about 1.01/1.02. Marginal, we seem to have a worthwhile trade-off here.

Full article: https://github.com/rails/rails/commit/697384df36a939e565b...

Tweets

Speed up String#blank? Regex by schneems · Pull...

github.com 25 Apr '16, 7am

[email protected] #commitcomment-17184696 . The regex to detect a blank string `/\A[[:space:]]*\z/` will loop through every ch...

既にサイズ欠け等出ていますが、本日より先行予約発売開始しております。 是非CHECKして下さい...

chapterworld.com 29 Apr '16, 3am

ABOVE adidas アディダス admiral アドミラル AIRWALK alife asics アシックス ballaholic BCR [email protected] betula BIRKENSTOCK ビルケンシュトック BRANDBLAC...