SlideShare uma empresa 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

Mais conteúdo relacionado

Destaque

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

Destaque (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
 

Semelhante a Codefellows lightning talk

CS 354 Procedural Methods
CS 354 Procedural MethodsCS 354 Procedural Methods
CS 354 Procedural MethodsMark Kilgard
 
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++Mike Acton
 
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)Johan Andersson
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in RubyVesna Doknic
 
Cryptography (under)engineering
Cryptography (under)engineeringCryptography (under)engineering
Cryptography (under)engineeringslicklash
 
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 DaviesJAXLondon_Conference
 
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 gameFelipe Prado
 
Computer Systems
Computer SystemsComputer Systems
Computer Systemsdrs
 
New Computer Systems
New Computer SystemsNew Computer Systems
New Computer Systemsmrsmackenzie
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Pptekul
 
Learning& Teaching Systems Ppt
Learning& Teaching  Systems PptLearning& Teaching  Systems Ppt
Learning& Teaching Systems PptNaruin
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems PptKyle
 
"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...Dataconomy Media
 
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 throughputPaolo Negri
 
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 ThroughputWooga
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud CitizenWooga
 
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.pptAsmitSilhare1
 

Semelhante 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

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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...Miguel Araújo
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 productivityPrincipled Technologies
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
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 AutomationSafe Software
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 

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!