SlideShare a Scribd company logo
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
 
wreewrer
wreewrerwreewrer
wreewrer
JohnHotyn
 
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
Arden 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 Style
Stephan 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 techniques
Marina 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 R
David 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 .docx
anhlodge
 
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
Cé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 fr
Cé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.docx
kenjordan97598
 
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 .docx
kenjordan97598
 
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 Curriculum
char 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 Specifications
Compact 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 communication
Pivorak 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 once
Pivorak MeetUp
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
Pivorak MeetUp
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
Pivorak MeetUp
 
Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)Ruby OOP (in Ukrainian)
Ruby OOP (in Ukrainian)
Pivorak MeetUp
 
Testing in Ruby
Testing in RubyTesting in Ruby
Testing in Ruby
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 Ruby
Pivorak 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 Pankowecki
Pivorak 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 Byno
Pivorak MeetUp
 
Successful Remote Development by Alex Rozumii
Successful Remote Development by Alex RozumiiSuccessful Remote Development by Alex Rozumii
Successful Remote Development by Alex Rozumii
Pivorak MeetUp
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming language
Pivorak 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 Kukunin
Pivorak MeetUp
 
CryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii MarkovetsCryptoParty: Introduction by Olexii Markovets
CryptoParty: Introduction by Olexii Markovets
Pivorak 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 Piasecki
Pivorak 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 Metal
Pivorak 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

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

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.