Slide 1

Slide 1 text

3VCZ5JQT 5

Slide 2

Slide 2 text

,WCPKVQ(CVCU !

Slide 3

Slide 3 text

@JuanitoFatas

Slide 4

Slide 4 text

@JuanitoFatas

Slide 5

Slide 5 text

@JuanitoFatas

Slide 6

Slide 6 text

@JuanitoFatas

Slide 7

Slide 7 text

0GY9CTPKPI UKPEG4WD[ 1

Slide 8

Slide 8 text

$JSDVMBS"SHVNFOU3FGFSFODF&SSPS def foo(foo=foo) foo end < 2.2.2 => No problems at all >= 2.2.2 => warning: circular argument reference - foo

Slide 9

Slide 9 text

$JSDVMBS"SHVNFOU3FGFSFODF&SSPS def foo(foo=foo()) foo end https://bugs.ruby-lang.org/issues/10314 Fixed

Slide 10

Slide 10 text

0GY9CTPKPI UKPEG4WD[ 2 4GI'ZR

Slide 11

Slide 11 text

-JUFSBM /http:\/\/ruby.sg/ %r{http://ruby.sg}

Slide 12

Slide 12 text

Character Properties http://ruby-doc.org/core-2.2.2/Regexp.html#class-Regexp-label-Character+Properties

Slide 13

Slide 13 text

\p{} $POTUSVDU

Slide 14

Slide 14 text

\p{Letter} -FUUFS a, b, c

Slide 15

Slide 15 text

\p{Mark} .BSL bon appétit qué pasa Köln

Slide 16

Slide 16 text

\p{Number} /VNCFS 1, 2, 3

Slide 17

Slide 17 text

\p{Punctuation} 1VODUVBUJPO , ; .

Slide 18

Slide 18 text

\p{Word} 8PSE Letter, Mark, Number, Connector_Punctuation

Slide 19

Slide 19 text

\p{Symbol} 4ZNCPM + = |

Slide 20

Slide 20 text

\p{Han} .BUDI$IJOFTF if your application goes to China

Slide 21

Slide 21 text

\p{Hiragana,Katakana} .BUDI+BQBOFTF

Slide 22

Slide 22 text

\p{Hangul} .BUDI,PSFBO

Slide 23

Slide 23 text

3 'PWOGTCDNG

Slide 24

Slide 24 text

users.sort { |a, b| a.balance <=> b.balance } users.sort_by(&:balance) TPSUWTTPSU@CZ

Slide 25

Slide 25 text

> Benchmark.ips do |x| x.report(" sort") { users.sort { |a, b| a.balance <=> b.balance } } x.report("sort_by") { users.sort_by(&:balance) } x.compare! end

Slide 26

Slide 26 text

Calculating ------------------------------------- sort 1.158k i/100ms sort_by 2.401k i/100ms ------------------------------------------------- sort 12.140k (± 4.9%) i/s - 61.374k sort_by 24.169k (± 4.0%) i/s - 122.451k Comparison: sort_by: 24168.9 i/s sort: 12139.8 i/s - 1.99x slower

Slide 27

Slide 27 text

users.sort_by(&:balance).take 3 NJO@CZWTTPSU@CZ users.min_by 3, &:balance R uby 2.2

Slide 28

Slide 28 text

> Benchmark.ips do |x| x.report("sort_by") { users.sort_by(&:balance).take 3 } x.report(" min_by") { users.min_by 3, &:balance } x.compare! end

Slide 29

Slide 29 text

Calculating ------------------------------------- sort_by 12.000 i/100ms min_by 44.000 i/100ms ------------------------------------------------- sort_by 126.314 (± 4.0%) i/s - 636.000 min_by 462.227 (± 5.2%) i/s - 2.332k Comparison: min_by: 462.2 i/s sort_by: 126.3 i/s - 3.66x slower

Slide 30

Slide 30 text

4 5VTKPI

Slide 31

Slide 31 text

$PODBUFOBUJPO "foo" + "bar" "foo".concat "bar" "foo" << "bar" "foo" "bar" JuanitoFatas/fast-ruby#string-concatenation-code ✈️

Slide 32

Slide 32 text

-POH4USJOH-JUFSBMT "How kind of you to let me come!" + "Now once again, where does it rain?" + "On the plain! On the plain!" + "And where's that blasted plain? " + "In Spain! In Spain! The three " + "The rain in Spain stays mainly in the plain! " + "The rain in Spain stays mainly in the plain!"

Slide 33

Slide 33 text

-POH4USJOH-JUFSBMT "How kind of you to let me come!" \ "Now once again, where does it rain?" \ "On the plain! On the plain!" \ "And where's that blasted plain? " \ "In Spain! In Spain! The three " \ "The rain in Spain stays mainly in the plain! " \ "The rain in Spain stays mainly in the plain!"

Slide 34

Slide 34 text

Calculating ------------------------------------- String#+ 37.856k i/100ms String#backslash 144.338k i/100ms ------------------------------------------------- String#+ 480.091k (± 4.7%) i/s - 2.423M String#backslash 5.608M (± 8.4%) i/s - 27.857M Comparison: String#backslash: 5608274.5 i/s String#+: 480091.3 i/s - 11.68x slower

Slide 35

Slide 35 text

(KPFKPI4WD[6KRU 5

Slide 36

Slide 36 text

3VCZ4UEMJC%PDT http://ruby-doc.org/stdlib-2.2.2/

Slide 37

Slide 37 text

http://thepugautomatic.com http://idiosyncratic-ruby.com http://www.rubytapas.com http://parley.rubyrogues.com

Slide 38

Slide 38 text

JuanitoFatas/fast-ruby JuanitoFatas/ruby-tips