SlideShare a Scribd company logo
1 of 23
Download to read offline
Bits of Ruby
Ἲtip to RGSoC­friendly confs
♥ eurucamp ♥ JRubyConf ♥ Deccan RubyConf ♥
♥ OTSConf ♥ Madison+ Ruby ♥ BaRuCo ♥
♥ Reject.JS ♥ Strange Loop ♥ RailsClub ♥
♥ EuRuKo ♥ Øredev ♥ ROSSConf ♥
♥ GOTO Conference ♥ dotJS ♥
sooo… who goes where?
Tate Isom Genevieve Ola Arielle
eurucamp ✓ ✓ ✓ ✓
JRubyConf ✓
ROSSConf ✓ ✓
BaRuCo ✓ ✓ ✓
EuRuKo ✓ ✓ ✓
…but how do we track who goes where?
name­keyed hash? conf­keyed hash?
how about a logical matrix?
oh of course! (what’s that…?)
a rectangular table of Boolean values
true / false relationship representation
c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o )
n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e )
m a t r i x = [
[ t r u e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] ,
[ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] ,
[ f a l s e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , t r u e , f a l s e , t r u e ] ,
]
m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > t r u e
m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > f a l s e
but that’s not very efficient
every conference adds a row
every participant adds a column
confs.size×(names.sizeBools+1Array)+1Array
how about using zeroes and ones instead?
logical matrix
m a t r i x = [
[ t r u e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] ,
[ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] ,
[ f a l s e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , t r u e , f a l s e , t r u e ] ,
]
bit matrix
m a t r i x = [
[ 1 , 1 , 1 , 0 , 1 ] ,
[ 1 , 0 , 0 , 0 , 0 ] ,
[ 0 , 0 , 0 , 1 , 1 ] ,
[ 0 , 1 , 1 , 0 , 1 ] ,
[ 1 , 0 , 1 , 0 , 1 ] ,
]
bit matrix
m a t r i x = [
0 b 1 1 1 0 1 ,
0 b 1 0 0 0 0 ,
0 b 0 0 0 1 1 ,
0 b 0 1 1 0 1 ,
0 b 1 0 1 0 1 ,
]
m a t r i x = [ 2 9 , 1 6 , 3 , 1 3 , 2 1 ]
how much better?
names.sizeFixnums+1Array   →   1Fixnum
Fixnums go up to 2E62-1
…that’s 4611686018427387903
…that’s 4_611_686_018_427_387_903
I’m better at estimating things
than probably 40 or 50 billion people.
— Randy Tayler
…that’s over four quintillion
but how do we query it?
c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o )
n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e )
m a t r i x = [
[ t r u e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] ,
[ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] ,
[ f a l s e , t r u e , t r u e , f a l s e , t r u e ] ,
[ t r u e , f a l s e , t r u e , f a l s e , t r u e ] ,
]
m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > t r u e
m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > f a l s e
Integer#[]
2 9 = = 0 b 1 1 1 0 1 # = > t r u e
2 9 [ 0 ] # = > 1
2 9 [ 1 ] # = > 0
2 9 [ 2 ] # = > 1
return the n­th least significant bit
c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o )
n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e ) . r e v e r s e
m a t r i x = [ 0 b 1 1 1 0 1 , 0 b 1 0 0 0 0 , 0 b 0 0 0 1 1 , 0 b 0 1 1 0 1 , 0 b 1 0 1 0 1 ]
m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > 1
m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > 0
so… how many go to each conf?
e u r u c a m p = m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] # = > [ t r u e , t r u e , t r u e , f a l s e , t r u e ]
e u r u c a m p . c o u n t ( t r u e ) # = > 4
e u r u c a m p = m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] # = > 0 b 1 1 1 0 1
e u r u c a m p . t o _ s ( 2 ) . c o u n t ( ' 1 ' ) # = > 4
number of ones in a binary representation
‘population count’
but to_s(2).count('1') is not very efficient
let’s freedom­patch Integer
c l a s s I n t e g e r
d e f p o p c o u n t _ t o _ s
t o _ s ( 2 ) . c o u n t ( ' 1 ' )
e n d
d e f p o p c o u n t _ c o n t _ s h i f t
c o u n t = 0
n u m b e r = s e l f
u n t i l n u m b e r = = 0
c o u n t + = n u m b e r & 1
n u m b e r > > = 1
e n d
c o u n t
e n d
e n d
c l a s s I n t e g e r
d e f p o p c o u n t _ b i t _ e l i m
c o u n t = 0
n u m b e r = s e l f
w h i l e n u m b e r ! = 0
n u m b e r & = n u m b e r - 1
c o u n t + = 1
e n d
c o u n t
e n d
d e f p o p c o u n t _ p r o g _ s h i f t
n u m b e r = s e l f
n u m b e r - = ( n u m b e r > > 1 ) & 0 x 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
n u m b e r = ( n u m b e r & 0 x 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ) + ( ( n u m b e r > > 2 ) & 0 x 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 )
n u m b e r = ( n u m b e r + ( n u m b e r > > 4 ) ) & 0 x 0 f 0 f 0 f 0 f 0 f 0 f 0 f 0 f
n u m b e r = ( n u m b e r + ( n u m b e r > > 8 ) ) & 0 x 0 0 f f 0 0 f f 0 0 f f 0 0 f f
n u m b e r = ( n u m b e r + ( n u m b e r > > 1 6 ) ) & 0 x 0 0 0 0 f f f f 0 0 0 0 f f f f
n u m b e r + = n u m b e r > > 3 2
( n u m b e r + ( n u m b e r > > 6 4 ) ) & 0 x f f
e n d
e n d
r e q u i r e ' i n l i n e '
c l a s s I n t e g e r
i n l i n e d o | b u i l d e r |
b u i l d e r . c '
i n t p o p c o u n t _ b i t _ e l i m _ c ( ) {
l o n g n u m b e r = N U M 2 L O N G ( s e l f ) ;
i n t c o u n t ;
f o r ( c o u n t = 0 ; n u m b e r ; c o u n t + + ) n u m b e r & = n u m b e r - 1 ;
r e t u r n c o u n t ;
}
'
e n d
i n l i n e d o | b u i l d e r |
b u i l d e r . c '
i n t p o p c o u n t _ b u i l t i n ( ) {
r e t u r n _ _ b u i l t i n _ p o p c o u n t l ( N U M 2 L O N G ( s e l f ) ) ;
}
'
e n d
e n d
c l a s s I n t e g e r
P O P C O U N T _ C A C H E = ( 0 x 0 0 0 0 . . 0 x f f f f ) . m a p { | n u m b e r | n u m b e r . t o _ s ( 2 ) . c o u n t ( ' 1 ' ) }
d e f p o p c o u n t _ c a c h e d
P O P C O U N T _ C A C H E [ s e l f & 0 x f f f f ] +
P O P C O U N T _ C A C H E [ s e l f > > 1 6 & 0 x f f f f ] +
P O P C O U N T _ C A C H E [ s e l f > > 3 2 & 0 x f f f f ] +
P O P C O U N T _ C A C H E [ s e l f > > 4 8 ]
e n d
e n d
r e q u i r e ' b e n c h m a r k / i p s '
m e t h o d s = I n t e g e r . i n s t a n c e _ m e t h o d s . g r e p ( / ^ p o p c o u n t _ / )
n u m b e r s = A r r a y . n e w ( 1 _ 0 0 0 ) { r a n d ( 0 . . . ( 2 * * 6 2 - 1 ) ) }
f a i l ' o o p s ' u n l e s s m e t h o d s . m a p { | m e t h | n u m b e r s . m a p ( & m e t h ) } . u n i q . s i z e = = 1
B e n c h m a r k . i p s d o | b e n c h |
m e t h o d s . e a c h d o | m e t h |
b e n c h . r e p o r t ( m e t h [ 9 . . - 1 ] ) { n u m b e r s . m a p ( & m e t h ) }
e n d
b e n c h . c o m p a r e !
e n d
W a r m i n g u p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
b i t _ e l i m 5 3 . 0 0 0 i / 1 0 0 m s
c a c h e d 2 7 6 . 0 0 0 i / 1 0 0 m s
c o n t _ s h i f t 1 7 . 0 0 0 i / 1 0 0 m s
p r o g _ s h i f t 1 3 1 . 0 0 0 i / 1 0 0 m s
t o _ s 6 9 . 0 0 0 i / 1 0 0 m s
b i t _ e l i m _ c 1 . 0 9 8 k i / 1 0 0 m s
b u i l t i n 1 . 4 5 3 k i / 1 0 0 m s
C a l c u l a t i n g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
b i t _ e l i m 5 4 1 . 1 2 7 ( ± 0 . 4 % ) i / s - 2 . 7 5 6 k
c a c h e d 2 . 8 0 6 k ( ± 0 . 3 % ) i / s - 1 4 . 0 7 6 k
c o n t _ s h i f t 1 8 9 . 9 2 1 ( ± 1 . 1 % ) i / s - 9 5 2 . 0 0 0
p r o g _ s h i f t 1 . 5 9 6 k ( ± 0 . 3 % ) i / s - 7 . 9 9 1 k
t o _ s 6 9 5 . 5 2 8 ( ± 0 . 4 % ) i / s - 3 . 5 1 9 k
b i t _ e l i m _ c 1 1 . 1 7 2 k ( ± 1 . 4 % ) i / s - 5 5 . 9 9 8 k
b u i l t i n 1 4 . 6 6 1 k ( ± 1 . 1 % ) i / s - 7 4 . 1 0 3 k
C o m p a r i s o n :
b u i l t i n : 1 4 6 6 1 . 1 i / s
b i t _ e l i m _ c : 1 1 1 7 1 . 8 i / s - 1 . 3 1 x s l o w e r
c a c h e d : 2 8 0 5 . 6 i / s - 5 . 2 3 x s l o w e r
p r o g _ s h i f t : 1 5 9 5 . 7 i / s - 9 . 1 9 x s l o w e r
t o _ s : 6 9 5 . 5 i / s - 2 1 . 0 8 x s l o w e r
b i t _ e l i m : 5 4 1 . 1 i / s - 2 7 . 0 9 x s l o w e r
c o n t _ s h i f t : 1 8 9 . 9 i / s - 7 7 . 2 0 x s l o w e r
Tate Isom Genevieve Ola Arielle
eurucamp ✓ ✓ ✓ ✓
JRubyConf ✓
ROSSConf ✓ ✓
BaRuCo ✓ ✓ ✓
EuRuKo ✓ ✓ ✓
Ἲtip to RGSoC­friendly confs
♥ eurucamp ♥ JRubyConf ♥ Deccan RubyConf ♥
♥ OTSConf ♥ Madison+ Ruby ♥ BaRuCo ♥
♥ Reject.JS ♥ Strange Loop ♥ RailsClub ♥
♥ EuRuKo ♥ Øredev ♥ ROSSConf ♥
♥ GOTO Conference ♥ dotJS ♥
thanks!
@chastell
talks.chastell.net

More Related Content

What's hot

Maurizio_Taffone_Emerging_Security_Threats
Maurizio_Taffone_Emerging_Security_ThreatsMaurizio_Taffone_Emerging_Security_Threats
Maurizio_Taffone_Emerging_Security_ThreatsMaurizio Taffone
 
military training
military trainingmilitary training
military trainingKelvin Xuna
 
Representing Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in OmekaRepresenting Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in OmekaArden Kirkland
 
Numbers1 wordsearch
Numbers1 wordsearchNumbers1 wordsearch
Numbers1 wordsearchyeepchin268
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With StyleStephan Hochhaus
 

What's hot (8)

1
11
1
 
Maurizio_Taffone_Emerging_Security_Threats
Maurizio_Taffone_Emerging_Security_ThreatsMaurizio_Taffone_Emerging_Security_Threats
Maurizio_Taffone_Emerging_Security_Threats
 
Soccer
SoccerSoccer
Soccer
 
military training
military trainingmilitary training
military training
 
wreewrer
wreewrerwreewrer
wreewrer
 
Representing Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in OmekaRepresenting Material Culture Online: Historic Clothing in Omeka
Representing Material Culture Online: Historic Clothing in Omeka
 
Numbers1 wordsearch
Numbers1 wordsearchNumbers1 wordsearch
Numbers1 wordsearch
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With Style
 

Similar to Piotr Szotkowski about "Bits of ruby"

Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Pivorak MeetUp
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet Pôle Systematic Paris-Region
 
Code GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniquesCode GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniquesMarina Kolpakova
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!Cédric Brun
 
Social Network Analysis With R
Social Network Analysis With RSocial Network Analysis With R
Social Network Analysis With RDavid Chiu
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamHenryk Konsek
 
Scanned by CamScannerT a b i c 4 2 0 13 2 0 14 V ( ï l .docx
Scanned by CamScannerT  a b i c  4 2 0 13 2 0 14  V ( ï l .docxScanned by CamScannerT  a b i c  4 2 0 13 2 0 14  V ( ï l .docx
Scanned by CamScannerT a b i c 4 2 0 13 2 0 14 V ( ï l .docxanhlodge
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldCédric Brun
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frCédric Brun
 
Scanned by CamScannerG o o d w M P r e p a id r e n t.docx
Scanned by CamScannerG o o d w M  P r e p a id  r e n t.docxScanned by CamScannerG o o d w M  P r e p a id  r e n t.docx
Scanned by CamScannerG o o d w M P r e p a id r e n t.docxkenjordan97598
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 DISID
 
Elements of mechanical engineering (notes)
Elements of mechanical engineering (notes)Elements of mechanical engineering (notes)
Elements of mechanical engineering (notes)Ahmad Sakib
 
Scanned by CamScannero u h a v e a tte m p te d th is .docx
Scanned by CamScannero u  h a v e  a tte m p te d  th is  .docxScanned by CamScannero u  h a v e  a tte m p te d  th is  .docx
Scanned by CamScannero u h a v e a tte m p te d th is .docxkenjordan97598
 
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...Johannes Bjerva
 
Certificates
CertificatesCertificates
CertificatesJeff CHen
 
Strategic Cartography: Identifying IL Intersections Across the Curriculum
Strategic Cartography: Identifying IL Intersections Across the CurriculumStrategic Cartography: Identifying IL Intersections Across the Curriculum
Strategic Cartography: Identifying IL Intersections Across the Curriculumchar booth
 
Compact Street Lights - 25W LED STELLAR STREET LIGHT Specifications
Compact Street Lights - 25W LED STELLAR STREET LIGHT SpecificationsCompact Street Lights - 25W LED STELLAR STREET LIGHT Specifications
Compact Street Lights - 25W LED STELLAR STREET LIGHT SpecificationsCompact Lighting
 
Continuous delivery with Gradle
Continuous delivery with GradleContinuous delivery with Gradle
Continuous delivery with GradleBob Paulin
 

Similar to Piotr Szotkowski about "Bits of ruby" (20)

Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
Code GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniquesCode GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniques
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!
 
Social Network Analysis With R
Social Network Analysis With RSocial Network Analysis With R
Social Network Analysis With R
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
 
Scanned by CamScannerT a b i c 4 2 0 13 2 0 14 V ( ï l .docx
Scanned by CamScannerT  a b i c  4 2 0 13 2 0 14  V ( ï l .docxScanned by CamScannerT  a b i c  4 2 0 13 2 0 14  V ( ï l .docx
Scanned by CamScannerT a b i c 4 2 0 13 2 0 14 V ( ï l .docx
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
 
Scanned by CamScannerG o o d w M P r e p a id r e n t.docx
Scanned by CamScannerG o o d w M  P r e p a id  r e n t.docxScanned by CamScannerG o o d w M  P r e p a id  r e n t.docx
Scanned by CamScannerG o o d w M P r e p a id r e n t.docx
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016
 
Elements of mechanical engineering (notes)
Elements of mechanical engineering (notes)Elements of mechanical engineering (notes)
Elements of mechanical engineering (notes)
 
Scanned by CamScannero u h a v e a tte m p te d th is .docx
Scanned by CamScannero u  h a v e  a tte m p te d  th is  .docxScanned by CamScannero u  h a v e  a tte m p te d  th is  .docx
Scanned by CamScannero u h a v e a tte m p te d th is .docx
 
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...
From Phonology to Syntax: Unsupervised Linguistic Typology at Different Level...
 
Transcripts and PC
Transcripts and PCTranscripts and PC
Transcripts and PC
 
Winload.efi.mui
Winload.efi.muiWinload.efi.mui
Winload.efi.mui
 
Certificates
CertificatesCertificates
Certificates
 
Strategic Cartography: Identifying IL Intersections Across the Curriculum
Strategic Cartography: Identifying IL Intersections Across the CurriculumStrategic Cartography: Identifying IL Intersections Across the Curriculum
Strategic Cartography: Identifying IL Intersections Across the Curriculum
 
Compact Street Lights - 25W LED STELLAR STREET LIGHT Specifications
Compact Street Lights - 25W LED STELLAR STREET LIGHT SpecificationsCompact Street Lights - 25W LED STELLAR STREET LIGHT Specifications
Compact Street Lights - 25W LED STELLAR STREET LIGHT Specifications
 
Continuous delivery with Gradle
Continuous delivery with GradleContinuous delivery with Gradle
Continuous delivery with Gradle
 

More from Pivorak MeetUp

Lisp(Lots of Irritating Superfluous Parentheses)
Lisp(Lots of Irritating Superfluous Parentheses)Lisp(Lots of Irritating Superfluous Parentheses)
Lisp(Lots of Irritating Superfluous Parentheses)Pivorak MeetUp
 
Some strange stories about mocks.
Some strange stories about mocks.Some strange stories about mocks.
Some strange stories about mocks.Pivorak MeetUp
 
Business-friendly library for inter-service communication
Business-friendly library for inter-service communicationBusiness-friendly library for inter-service communication
Business-friendly library for inter-service communicationPivorak MeetUp
 
How i was a team leader once
How i was a team leader onceHow i was a team leader once
How i was a team leader oncePivorak MeetUp
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiPivorak MeetUp
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukPivorak MeetUp
 
Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)Pivorak MeetUp
 
Ruby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Ruby Summer Course by #pivorak & OnApp - OOP Basics in RubyRuby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Ruby Summer Course by #pivorak & OnApp - OOP Basics in RubyPivorak MeetUp
 
The Saga Pattern: 2 years later by Robert Pankowecki
The Saga Pattern: 2 years later by Robert PankoweckiThe Saga Pattern: 2 years later by Robert Pankowecki
The Saga Pattern: 2 years later by Robert PankoweckiPivorak MeetUp
 
Data and Bounded Contexts by Volodymyr Byno
Data and Bounded Contexts by Volodymyr BynoData and Bounded Contexts by Volodymyr Byno
Data and Bounded Contexts by Volodymyr BynoPivorak MeetUp
 
Successful Remote Development by Alex Rozumii
Successful Remote Development by Alex RozumiiSuccessful Remote Development by Alex Rozumii
Successful Remote Development by Alex RozumiiPivorak MeetUp
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming languagePivorak MeetUp
 
Functional Immutable CSS
Functional Immutable CSS Functional Immutable CSS
Functional Immutable CSS Pivorak MeetUp
 
Multi language FBP with Flowex by Anton Mishchuk
Multi language FBP with Flowex by Anton Mishchuk Multi language FBP with Flowex by Anton Mishchuk
Multi language FBP with Flowex by Anton Mishchuk Pivorak MeetUp
 
Detective story of one clever user - Lightning Talk By Sergiy Kukunin
Detective story of one clever user - Lightning Talk By Sergiy KukuninDetective story of one clever user - Lightning Talk By Sergiy Kukunin
Detective story of one clever user - Lightning Talk By Sergiy KukuninPivorak MeetUp
 
CryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii MarkovetsCryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii MarkovetsPivorak MeetUp
 
How to make first million by 30 (or not, but tryin') - by Marek Piasecki
How to make first million by 30 (or not, but tryin') - by Marek PiaseckiHow to make first million by 30 (or not, but tryin') - by Marek Piasecki
How to make first million by 30 (or not, but tryin') - by Marek PiaseckiPivorak MeetUp
 
GIS on Rails by Oleksandr Kychun
GIS on Rails by Oleksandr Kychun GIS on Rails by Oleksandr Kychun
GIS on Rails by Oleksandr Kychun Pivorak MeetUp
 
Unikernels - Keep It Simple to the Bare Metal
Unikernels - Keep It Simple to the Bare MetalUnikernels - Keep It Simple to the Bare Metal
Unikernels - Keep It Simple to the Bare MetalPivorak MeetUp
 

More from Pivorak MeetUp (20)

Lisp(Lots of Irritating Superfluous Parentheses)
Lisp(Lots of Irritating Superfluous Parentheses)Lisp(Lots of Irritating Superfluous Parentheses)
Lisp(Lots of Irritating Superfluous Parentheses)
 
Some strange stories about mocks.
Some strange stories about mocks.Some strange stories about mocks.
Some strange stories about mocks.
 
Business-friendly library for inter-service communication
Business-friendly library for inter-service communicationBusiness-friendly library for inter-service communication
Business-friendly library for inter-service communication
 
How i was a team leader once
How i was a team leader onceHow i was a team leader once
How i was a team leader once
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
 
Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)
 
Testing in Ruby
Testing in RubyTesting in Ruby
Testing in Ruby
 
Ruby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Ruby Summer Course by #pivorak & OnApp - OOP Basics in RubyRuby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Ruby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
 
The Saga Pattern: 2 years later by Robert Pankowecki
The Saga Pattern: 2 years later by Robert PankoweckiThe Saga Pattern: 2 years later by Robert Pankowecki
The Saga Pattern: 2 years later by Robert Pankowecki
 
Data and Bounded Contexts by Volodymyr Byno
Data and Bounded Contexts by Volodymyr BynoData and Bounded Contexts by Volodymyr Byno
Data and Bounded Contexts by Volodymyr Byno
 
Successful Remote Development by Alex Rozumii
Successful Remote Development by Alex RozumiiSuccessful Remote Development by Alex Rozumii
Successful Remote Development by Alex Rozumii
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming language
 
Functional Immutable CSS
Functional Immutable CSS Functional Immutable CSS
Functional Immutable CSS
 
Multi language FBP with Flowex by Anton Mishchuk
Multi language FBP with Flowex by Anton Mishchuk Multi language FBP with Flowex by Anton Mishchuk
Multi language FBP with Flowex by Anton Mishchuk
 
Detective story of one clever user - Lightning Talk By Sergiy Kukunin
Detective story of one clever user - Lightning Talk By Sergiy KukuninDetective story of one clever user - Lightning Talk By Sergiy Kukunin
Detective story of one clever user - Lightning Talk By Sergiy Kukunin
 
CryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii MarkovetsCryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii Markovets
 
How to make first million by 30 (or not, but tryin') - by Marek Piasecki
How to make first million by 30 (or not, but tryin') - by Marek PiaseckiHow to make first million by 30 (or not, but tryin') - by Marek Piasecki
How to make first million by 30 (or not, but tryin') - by Marek Piasecki
 
GIS on Rails by Oleksandr Kychun
GIS on Rails by Oleksandr Kychun GIS on Rails by Oleksandr Kychun
GIS on Rails by Oleksandr Kychun
 
Unikernels - Keep It Simple to the Bare Metal
Unikernels - Keep It Simple to the Bare MetalUnikernels - Keep It Simple to the Bare Metal
Unikernels - Keep It Simple to the Bare Metal
 

Recently uploaded

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 

Recently uploaded (20)

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 

Piotr Szotkowski about "Bits of ruby"

  • 2.
  • 4. sooo… who goes where? Tate Isom Genevieve Ola Arielle eurucamp ✓ ✓ ✓ ✓ JRubyConf ✓ ROSSConf ✓ ✓ BaRuCo ✓ ✓ ✓ EuRuKo ✓ ✓ ✓ …but how do we track who goes where? name­keyed hash? conf­keyed hash? how about a logical matrix?
  • 5. oh of course! (what’s that…?) a rectangular table of Boolean values true / false relationship representation c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o ) n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e ) m a t r i x = [ [ t r u e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] , [ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] , [ f a l s e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , t r u e , f a l s e , t r u e ] , ] m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > t r u e m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > f a l s e
  • 7. logical matrix m a t r i x = [ [ t r u e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] , [ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] , [ f a l s e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , t r u e , f a l s e , t r u e ] , ]
  • 8. bit matrix m a t r i x = [ [ 1 , 1 , 1 , 0 , 1 ] , [ 1 , 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 1 , 1 ] , [ 0 , 1 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 , 1 ] , ]
  • 9. bit matrix m a t r i x = [ 0 b 1 1 1 0 1 , 0 b 1 0 0 0 0 , 0 b 0 0 0 1 1 , 0 b 0 1 1 0 1 , 0 b 1 0 1 0 1 , ] m a t r i x = [ 2 9 , 1 6 , 3 , 1 3 , 2 1 ]
  • 11. but how do we query it? c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o ) n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e ) m a t r i x = [ [ t r u e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , f a l s e , f a l s e , f a l s e ] , [ f a l s e , f a l s e , f a l s e , t r u e , t r u e ] , [ f a l s e , t r u e , t r u e , f a l s e , t r u e ] , [ t r u e , f a l s e , t r u e , f a l s e , t r u e ] , ] m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > t r u e m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > f a l s e
  • 12. Integer#[] 2 9 = = 0 b 1 1 1 0 1 # = > t r u e 2 9 [ 0 ] # = > 1 2 9 [ 1 ] # = > 0 2 9 [ 2 ] # = > 1 return the n­th least significant bit c o n f s = % w ( e u r u c a m p J R u b y C o n f R O S S C o n f B a R u C o E u R u K o ) n a m e s = % w ( T a t e I s o m G e n e v i e v e O l a A r i e l l e ) . r e v e r s e m a t r i x = [ 0 b 1 1 1 0 1 , 0 b 1 0 0 0 0 , 0 b 0 0 0 1 1 , 0 b 0 1 1 0 1 , 0 b 1 0 1 0 1 ] m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] [ n a m e s . i n d e x ( ' T a t e ' ) ] # = > 1 m a t r i x [ c o n f s . i n d e x ( ' R O S S C o n f ' ) ] [ n a m e s . i n d e x ( ' G e n e v i e v e ' ) ] # = > 0
  • 13. so… how many go to each conf? e u r u c a m p = m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] # = > [ t r u e , t r u e , t r u e , f a l s e , t r u e ] e u r u c a m p . c o u n t ( t r u e ) # = > 4 e u r u c a m p = m a t r i x [ c o n f s . i n d e x ( ' e u r u c a m p ' ) ] # = > 0 b 1 1 1 0 1 e u r u c a m p . t o _ s ( 2 ) . c o u n t ( ' 1 ' ) # = > 4 number of ones in a binary representation ‘population count’ but to_s(2).count('1') is not very efficient
  • 14. let’s freedom­patch Integer c l a s s I n t e g e r d e f p o p c o u n t _ t o _ s t o _ s ( 2 ) . c o u n t ( ' 1 ' ) e n d d e f p o p c o u n t _ c o n t _ s h i f t c o u n t = 0 n u m b e r = s e l f u n t i l n u m b e r = = 0 c o u n t + = n u m b e r & 1 n u m b e r > > = 1 e n d c o u n t e n d e n d
  • 15. c l a s s I n t e g e r d e f p o p c o u n t _ b i t _ e l i m c o u n t = 0 n u m b e r = s e l f w h i l e n u m b e r ! = 0 n u m b e r & = n u m b e r - 1 c o u n t + = 1 e n d c o u n t e n d d e f p o p c o u n t _ p r o g _ s h i f t n u m b e r = s e l f n u m b e r - = ( n u m b e r > > 1 ) & 0 x 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 n u m b e r = ( n u m b e r & 0 x 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ) + ( ( n u m b e r > > 2 ) & 0 x 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ) n u m b e r = ( n u m b e r + ( n u m b e r > > 4 ) ) & 0 x 0 f 0 f 0 f 0 f 0 f 0 f 0 f 0 f n u m b e r = ( n u m b e r + ( n u m b e r > > 8 ) ) & 0 x 0 0 f f 0 0 f f 0 0 f f 0 0 f f n u m b e r = ( n u m b e r + ( n u m b e r > > 1 6 ) ) & 0 x 0 0 0 0 f f f f 0 0 0 0 f f f f n u m b e r + = n u m b e r > > 3 2 ( n u m b e r + ( n u m b e r > > 6 4 ) ) & 0 x f f e n d e n d
  • 16. r e q u i r e ' i n l i n e ' c l a s s I n t e g e r i n l i n e d o | b u i l d e r | b u i l d e r . c ' i n t p o p c o u n t _ b i t _ e l i m _ c ( ) { l o n g n u m b e r = N U M 2 L O N G ( s e l f ) ; i n t c o u n t ; f o r ( c o u n t = 0 ; n u m b e r ; c o u n t + + ) n u m b e r & = n u m b e r - 1 ; r e t u r n c o u n t ; } ' e n d i n l i n e d o | b u i l d e r | b u i l d e r . c ' i n t p o p c o u n t _ b u i l t i n ( ) { r e t u r n _ _ b u i l t i n _ p o p c o u n t l ( N U M 2 L O N G ( s e l f ) ) ; } ' e n d e n d
  • 17. c l a s s I n t e g e r P O P C O U N T _ C A C H E = ( 0 x 0 0 0 0 . . 0 x f f f f ) . m a p { | n u m b e r | n u m b e r . t o _ s ( 2 ) . c o u n t ( ' 1 ' ) } d e f p o p c o u n t _ c a c h e d P O P C O U N T _ C A C H E [ s e l f & 0 x f f f f ] + P O P C O U N T _ C A C H E [ s e l f > > 1 6 & 0 x f f f f ] + P O P C O U N T _ C A C H E [ s e l f > > 3 2 & 0 x f f f f ] + P O P C O U N T _ C A C H E [ s e l f > > 4 8 ] e n d e n d
  • 18. r e q u i r e ' b e n c h m a r k / i p s ' m e t h o d s = I n t e g e r . i n s t a n c e _ m e t h o d s . g r e p ( / ^ p o p c o u n t _ / ) n u m b e r s = A r r a y . n e w ( 1 _ 0 0 0 ) { r a n d ( 0 . . . ( 2 * * 6 2 - 1 ) ) } f a i l ' o o p s ' u n l e s s m e t h o d s . m a p { | m e t h | n u m b e r s . m a p ( & m e t h ) } . u n i q . s i z e = = 1 B e n c h m a r k . i p s d o | b e n c h | m e t h o d s . e a c h d o | m e t h | b e n c h . r e p o r t ( m e t h [ 9 . . - 1 ] ) { n u m b e r s . m a p ( & m e t h ) } e n d b e n c h . c o m p a r e ! e n d
  • 19. W a r m i n g u p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - b i t _ e l i m 5 3 . 0 0 0 i / 1 0 0 m s c a c h e d 2 7 6 . 0 0 0 i / 1 0 0 m s c o n t _ s h i f t 1 7 . 0 0 0 i / 1 0 0 m s p r o g _ s h i f t 1 3 1 . 0 0 0 i / 1 0 0 m s t o _ s 6 9 . 0 0 0 i / 1 0 0 m s b i t _ e l i m _ c 1 . 0 9 8 k i / 1 0 0 m s b u i l t i n 1 . 4 5 3 k i / 1 0 0 m s C a l c u l a t i n g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - b i t _ e l i m 5 4 1 . 1 2 7 ( ± 0 . 4 % ) i / s - 2 . 7 5 6 k c a c h e d 2 . 8 0 6 k ( ± 0 . 3 % ) i / s - 1 4 . 0 7 6 k c o n t _ s h i f t 1 8 9 . 9 2 1 ( ± 1 . 1 % ) i / s - 9 5 2 . 0 0 0 p r o g _ s h i f t 1 . 5 9 6 k ( ± 0 . 3 % ) i / s - 7 . 9 9 1 k t o _ s 6 9 5 . 5 2 8 ( ± 0 . 4 % ) i / s - 3 . 5 1 9 k b i t _ e l i m _ c 1 1 . 1 7 2 k ( ± 1 . 4 % ) i / s - 5 5 . 9 9 8 k b u i l t i n 1 4 . 6 6 1 k ( ± 1 . 1 % ) i / s - 7 4 . 1 0 3 k C o m p a r i s o n : b u i l t i n : 1 4 6 6 1 . 1 i / s b i t _ e l i m _ c : 1 1 1 7 1 . 8 i / s - 1 . 3 1 x s l o w e r c a c h e d : 2 8 0 5 . 6 i / s - 5 . 2 3 x s l o w e r p r o g _ s h i f t : 1 5 9 5 . 7 i / s - 9 . 1 9 x s l o w e r t o _ s : 6 9 5 . 5 i / s - 2 1 . 0 8 x s l o w e r b i t _ e l i m : 5 4 1 . 1 i / s - 2 7 . 0 9 x s l o w e r c o n t _ s h i f t : 1 8 9 . 9 i / s - 7 7 . 2 0 x s l o w e r
  • 20. Tate Isom Genevieve Ola Arielle eurucamp ✓ ✓ ✓ ✓ JRubyConf ✓ ROSSConf ✓ ✓ BaRuCo ✓ ✓ ✓ EuRuKo ✓ ✓ ✓
  • 21.