Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
base: c79f437eb09c
Choose a base ref
...
head repository: crystal-lang/crystal
compare: 6d1a6a71880b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 26, 2017

  1. Relocate and document Time::DayOfWeek

    Consolidate `Time::DayOfWeek` definition inside `Time`, adding documentation
    and examples on its usage.
    
    Refactor day question methods (ie `#monday?`) macro to use Enum's constants
    and question methods, avoiding duplication of definitions.
    
    This change does not introduce performance penalties by itself, but a
    synthetic benchmark might present it otherwise:
    
        day_of_week.value == index: 626.33M (   1.6ns) (±10.72%)       fastest
             day_of_week.question?: 621.56M (  1.61ns) (±10.35%)  1.01× slower
    
        dow.value == index: 622.68M (  1.61ns) (± 9.82%)  1.00× slower
             dow.question?: 624.23M (   1.6ns) (±10.82%)       fastest
    
    Benchmark code:
    
        require "benchmark"
    
        time = Time.new(2016, 2, 15)
        dow = time.day_of_week
    
        # benchmark against `day_of_week` being computed each time
        Benchmark.ips do |results|
          results.report("day_of_week.value == index:") { time.day_of_week.value == 1 }
          results.report("day_of_week.question?:") { time.day_of_week.monday? }
        end
    
        # benchmark against cached `day_of_week`
        Benchmark.ips do |results|
          results.report("dow.value == index:") { dow.value == 1 }
          results.report("dow.question?:") { dow.monday? }
        end
    luislavena committed Oct 26, 2017
    Copy the full SHA
    2006b44 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2017

  1. Merge pull request #5188 from luislavena/refactor-day-of-the-week

    Relocate and document Time::DayOfWeek
    asterite committed Oct 27, 2017
    Copy the full SHA
    6d1a6a7 View commit details
    Browse the repository at this point in the history