Last active
February 25, 2022 17:19
-
-
Save lewispb/577db0cf4c75a23f6e07101df3c3488b to your computer and use it in GitHub Desktop.
Revisions
-
lewispb revised this gist
Feb 25, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,8 @@ unique_list_legacy = Kredis.unique_list_legacy "uniquelist_list" # Populate the lists with some initial data unique_list.append((1_000..100_000).map(&:to_s)) unique_list_legacy.append((1_000..100_000).map(&:to_s)) Benchmark.bm do |benchmark| benchmark.report("unique_list (sorted set)") do -
lewispb created this gist
Feb 25, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "rails" gem "kredis", github: "lewispb/kredis", branch: "unique_list_with_sorted_set" end Kredis.configurator = Class.new { def config_for(name) { db: "1" } end }.new $VERBOSE = nil unique_list = Kredis.unique_list "uniquelist_sortedset" unique_list_legacy = Kredis.unique_list_legacy "uniquelist_list" # Populate the lists with some initial data unique_list.append((1..100_000).map(&:to_s)) unique_list_legacy.append((1..100_000).map(&:to_s)) Benchmark.bm do |benchmark| benchmark.report("unique_list (sorted set)") do 1_000.times do |n| unique_list.append(n) end end benchmark.report("unique_list (list)") do 1_000.times do |n| unique_list_legacy.append(n) end end end unique_list.del unique_list_legacy.del