github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

didip / mysql-profile

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 64c6ea6

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

profiling mysql, especially useful to compare against key-value databases — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

lower str length to 16 
didip (author)
Tue Apr 28 22:00:14 -0700 2009
commit  64c6ea6f3b541f9ac2f75e8409c94fffe04cc195
tree    6777cb8ce907fd341ffcebc055046c2c619c8144
parent  a6b685a130f99fead72d706d81ca930db99903aa
mysql-profile / write_profile.rb write_profile.rb
100644 51 lines (41 sloc) 1.201 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require "rubygems"
require "ruby-prof"
require 'mysql'
# ----------------------------------
# Setup
 
def print_profile(result)
  if result
    printer = RubyProf::FlatPrinter.new(result)
    printer.print(STDOUT, 0)
  else
    puts "There are no result to print."
  end
end
 
# ------------------------------------------
# Setup functions
 
def create_db_statement
  return "CREATE DATABASE mysql_profile"
end
 
def create_table_statement
  return "CREATE TABLE target (id INT, data TEXT) TYPE=innodb;"
end
 
def insert_statement(table_name, column_name, value)
  return "INSERT INTO #{table_name} (#{column_name}) VALUES ('#{value}')"
end
 
# ----------------------------------------
# Profile test functions
 
def write_many_profile(connection, num_times, value=nil)
  puts "Write #{num_times} rows with string-length: #{value.length}"
  result = RubyProf.profile do
    num_times.times do |i|
      connection.query(insert_statement('target', 'data', value))
    end
  end
  print_profile(result)
end
 
# ----------------------------------
# Start Testing
 
my = Mysql::new("localhost", "root", "", "mysql_profile")
num_times = 10000
string_length = 16
 
write_many_profile(my, num_times, 'a'*string_length)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server