This file contains 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 characters
hanke@soyuz:performance:[master *] chruby 1.9 | |
hanke@soyuz:performance:[master *] perfer run -m 5 perfer.rb | |
Sanity check: | |
>|2014-01-04 21:34:25|0.000096|florian | 1| 0| 1| | |
Session Search#search with ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0] | |
Taking 5 measurements of at least 1.0s | |
Search#search('florian') with variable index size and fixed search size 1024 in 68.06 ms ± 6.077 ( 8.9%) | |
Search#search('florian') with variable index size and fixed search size 2048 in 82.98 ms ± 6.361 ( 7.7%) |
This file contains 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 characters
s = "One Two Three" # Shorter than 24 characters. | |
s.split /\s/ # Uncomment and comment. Why does the original string now occur 2 more times (1 per match?) in the ObjectSpace than without splitting? | |
times = 0 | |
ObjectSpace.each_object(String) do |str| | |
times += 1 if str == s | |
end | |
p times |
This file contains 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 characters
~/bin $ cat prettyprint | |
#!/bin/sh | |
PDF_FILE=/tmp/temp.pdf | |
PS_FILE=/tmp/temp.ps | |
vim \ | |
"+set number" "+syntax on" "+color slate" \ | |
"+set printoptions=number:y" \ | |
"+set printfont=courier:h9" \ |
This file contains 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 characters
# SETUP. | |
# | |
require 'picky' | |
# Users have a name and a list of blocked_ids. | |
# | |
User = Struct.new(:id, :name, :blocked_ids) do | |
# Generates a list of users which have not blocked this user. | |
# Note: Also excludes self. |
This file contains 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 characters
require 'picky' | |
Person = Struct.new :id, :age, :name | |
data = Picky::Index.new :people do | |
category :age, partial: Picky::Partial::None.new | |
category :name | |
end | |
data.replace Person.new(1, 34, 'Florian') |
This file contains 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 characters
require 'picky' | |
Person = Struct.new :id, :age, :name | |
data = Picky::Index.new :people do | |
category :age, partial: Picky::Partial::None.new | |
category :name, partial: Picky::Partial::Infix.new(min: 1, max: -1) | |
end | |
data.replace Person.new(1, 34, 'Florian') |
This file contains 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 characters
#!/usr/bin/env ruby | |
# | |
# Usage: | |
# p [pattern ...] | |
# | |
# Example: | |
# p E*.mp3 pop/A*.mp3 | |
# | |
files = Dir[ARGV.shift || '*.mp3', *ARGV].shuffle |
This file contains 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 characters
# Run using | |
# ruby facets.rb | |
# | |
require 'picky' | |
# Define index. | |
# | |
data = Picky::Index.new :models do | |
category :id | |
category :name |
This file contains 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 characters
# Module that handles object pool behaviour | |
# for you. | |
# | |
# Usage: | |
# class Thing | |
# extend Pool | |
# | |
# def initialize a, b, c | |
# @a, @b, @c = a, b, c | |
# end |
This file contains 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 characters
# Remove the Sinatra class from the Picky example app | |
# and replace the get call with this: | |
# | |
# Then, run e.g. | |
# ab -n 1000 -c 10 '127.0.0.1:3000/?query=a&ids=20&offset=0' | |
# (simple) | |
# or | |
# ab -n 1000 -c 10 '127.0.0.1:3000/?query=a*-a*-a&ids=20&offset=0' | |
# (complex) | |
# |
NewerOlder