SlideShare una empresa de Scribd logo
1 de 8
A little bit about numbers and
caching in Ruby
Kathryn Blackley, @keblackley
24 July 2013
CodeFellows, Seattle, WA
Scenario: you want to put a number into your Rails app.
Do you want…
A float? 6.2321, 113592.2, 0.0000012
An integer? 4, -18, 343338
A rational? (2/3), (-1/4), (29/8)
What’s the difference behind the scenes?
Written in binary (base 2)
0 = 0
2 = 10
1 = 1
3 = 11
4 = 100
ON
OFF
Each switch is a called bit.
Ruby integers: fixnum and bignum
Fixnum – limited by length of word in your operating
system: 32 bit or 64 bit.
Bignum – an object is allocated so there’s one bit per
digit required (in binary).
Ruby automatically transitions
Float
However your computer does numbers:
“double-precision floating-point format”
Uses powers of 2 and a significand to represent
numbers.
Problems with limited precision possible.
Q: Where’s this all happening in your computer?
A: In the CPU!
Q: So, where’s that?
CPU
registers
RAM
Hard drive
CPU: central processing unit
RAM: random access memory
Back to Ruby and Rails:
Caching in your rails app is dependent on the environment:
Default is OFF in development and testing
Default is ON in production
Can modify in config/environments
Why cache in your app?
Optimize your app  scalability
Good to know looking ahead to when your app is extremely popular!
Further resource
regarding caching:
http://guides.rubyonrails.org/caching_with_rails.html

Más contenido relacionado

Destacado

Gear swap powerpoint codefellows silver
Gear swap powerpoint codefellows silverGear swap powerpoint codefellows silver
Gear swap powerpoint codefellows silver
keb97
 
Caes gen presentation
Caes gen presentationCaes gen presentation
Caes gen presentation
LukeBatten
 
Comparisons of tidal barrages worldwide
Comparisons of tidal barrages worldwideComparisons of tidal barrages worldwide
Comparisons of tidal barrages worldwide
LukeBatten
 
Overall presentation
Overall presentationOverall presentation
Overall presentation
LukeBatten
 
Caes projects worldwide
Caes projects worldwideCaes projects worldwide
Caes projects worldwide
LukeBatten
 

Destacado (10)

Gear swap powerpoint codefellows silver
Gear swap powerpoint codefellows silverGear swap powerpoint codefellows silver
Gear swap powerpoint codefellows silver
 
Dominos Coupon Codes From CouponCloud
Dominos Coupon Codes From CouponCloudDominos Coupon Codes From CouponCloud
Dominos Coupon Codes From CouponCloud
 
Americord information kit
Americord information kitAmericord information kit
Americord information kit
 
Americord cord blood. simplified.
Americord cord blood. simplified.Americord cord blood. simplified.
Americord cord blood. simplified.
 
Caes gen presentation
Caes gen presentationCaes gen presentation
Caes gen presentation
 
Comparisons of tidal barrages worldwide
Comparisons of tidal barrages worldwideComparisons of tidal barrages worldwide
Comparisons of tidal barrages worldwide
 
Tuberculosis 57
Tuberculosis 57Tuberculosis 57
Tuberculosis 57
 
Overall presentation
Overall presentationOverall presentation
Overall presentation
 
Autoclave Steam Sterilizer - Pharmaceutical
Autoclave Steam Sterilizer - PharmaceuticalAutoclave Steam Sterilizer - Pharmaceutical
Autoclave Steam Sterilizer - Pharmaceutical
 
Caes projects worldwide
Caes projects worldwideCaes projects worldwide
Caes projects worldwide
 

Similar a Codefellows lightning talk

Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
ekul
 
Learning& Teaching Systems Ppt
Learning& Teaching  Systems PptLearning& Teaching  Systems Ppt
Learning& Teaching Systems Ppt
Naruin
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
Kyle
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to Throughput
Wooga
 

Similar a Codefellows lightning talk (20)

CS 354 Procedural Methods
CS 354 Procedural MethodsCS 354 Procedural Methods
CS 354 Procedural Methods
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
Parallel Futures of a Game Engine (v2.0)
Parallel Futures of a Game Engine (v2.0)Parallel Futures of a Game Engine (v2.0)
Parallel Futures of a Game Engine (v2.0)
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in Ruby
 
Cryptography (under)engineering
Cryptography (under)engineeringCryptography (under)engineering
Cryptography (under)engineering
 
Architecting for a scalable enterprise - John Davies
Architecting for a scalable enterprise - John DaviesArchitecting for a scalable enterprise - John Davies
Architecting for a scalable enterprise - John Davies
 
DEF CON 23 - Tamas Szakaly - shall we play a game
DEF CON 23 - Tamas Szakaly - shall we play a gameDEF CON 23 - Tamas Szakaly - shall we play a game
DEF CON 23 - Tamas Szakaly - shall we play a game
 
Computer Systems
Computer SystemsComputer Systems
Computer Systems
 
New Computer Systems
New Computer SystemsNew Computer Systems
New Computer Systems
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
 
Learning& Teaching Systems Ppt
Learning& Teaching  Systems PptLearning& Teaching  Systems Ppt
Learning& Teaching Systems Ppt
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to Throughput
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
 
UNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.pptUNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.ppt
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Codefellows lightning talk

  • 1. A little bit about numbers and caching in Ruby Kathryn Blackley, @keblackley 24 July 2013 CodeFellows, Seattle, WA
  • 2. Scenario: you want to put a number into your Rails app. Do you want… A float? 6.2321, 113592.2, 0.0000012 An integer? 4, -18, 343338 A rational? (2/3), (-1/4), (29/8) What’s the difference behind the scenes?
  • 3. Written in binary (base 2) 0 = 0 2 = 10 1 = 1 3 = 11 4 = 100 ON OFF Each switch is a called bit.
  • 4. Ruby integers: fixnum and bignum Fixnum – limited by length of word in your operating system: 32 bit or 64 bit. Bignum – an object is allocated so there’s one bit per digit required (in binary). Ruby automatically transitions
  • 5. Float However your computer does numbers: “double-precision floating-point format” Uses powers of 2 and a significand to represent numbers. Problems with limited precision possible.
  • 6. Q: Where’s this all happening in your computer? A: In the CPU! Q: So, where’s that? CPU registers RAM Hard drive CPU: central processing unit RAM: random access memory
  • 7. Back to Ruby and Rails: Caching in your rails app is dependent on the environment: Default is OFF in development and testing Default is ON in production Can modify in config/environments Why cache in your app? Optimize your app  scalability Good to know looking ahead to when your app is extremely popular!