Mysql doesn't auto lock or version lock records when select in repeatable read transactions. While PG can forbid concurrent updates.
The test table DDL in PG:
create table articles (
"id" serial,
"n" integer
);| /* | |
| benchmark with gtime -f "%M" | |
| pool alloc: | |
| time: 0.028571 | |
| 22331392 | |
| malloc: |
Mysql doesn't auto lock or version lock records when select in repeatable read transactions. While PG can forbid concurrent updates.
The test table DDL in PG:
create table articles (
"id" serial,
"n" integer
);http://ruby-china.org/topics/16256
get https://github.com/mvj3/hangman/blob/master/data/words.txt
and compile the decision tree.json
ruby compile.rb| import java.security.*; | |
| import javax.crypto.*; | |
| import javax.crypto.spec.*; | |
| import java.io.*; | |
| class aes{ | |
| static byte[] ptext; | |
| static SecretKeySpec key; | |
| public static void main(String[] args) throws Exception { |
| #!/usr/bin/env ruby | |
| name = File.basename ENV['TM_FILENAME'] | |
| name = name.dup | |
| name[/\.rb$/] = '' | |
| names = [] | |
| File.read(File.join(ENV['TM_PROJECT_DIRECTORY'], 'db/schema.rb')).scan(/( create_table "(\w+).*? end)/m) do |s, n| | |
| names << [n.size, s] if n.start_with?(name) | |
| end |
| def f n | |
| half = n / 2 | |
| table = Hash.new 0 | |
| ('0' * half).upto '9' * half do |s| | |
| sum = s.chars.map(&:to_i).inject(:+) | |
| table[sum] += 1 | |
| end | |
| r = 0 | |
| table.each do |_, v| | |
| r += v*v |
| # simulate template rendering | |
| class Template < Struct.new(:name) | |
| def render | |
| puts "#{name}_begin" | |
| r = "#{name}_begin\n" | |
| r << yield if block_given? | |
| puts "#{name}_end\n" | |
| r << "#{name}_end\n" | |
| end | |
| end |
| #! /usr/bin/env ruby | |
| str = $stdin.read | |
| if RUBY_VERSION < '1.9' | |
| print str | |
| exit | |
| end | |
| str.force_encoding 'utf-8' | |
| str.gsub! /(\p{Han})([a-zA-Z0-9\(\)\[\]\{\}])/u do | |
| "#$1 #$2" |
| class S < Struct | |
| def inspect | |
| pretty_inspect # may be not defined yet, don't alias | |
| end | |
| def pretty_print(q) | |
| q.group(1, sprintf("<%s", PP.mcall(self, Kernel, :class).name.split('::').last), '>') { | |
| q.seplist(PP.mcall(self, Struct, :members), lambda { q.text "," }) {|member| | |
| q.breakable | |
| q.text member.to_s |
| RSpec.configure do |config| | |
| if config.formatters.first.class.to_s =~ /TextMate/ | |
| def puts *xs | |
| xs.each do |x| | |
| $stdout.puts "<pre style='word-wrap:break-word;word-break:break-all;'>#{CGI.escape_html x.to_s}</pre>" | |
| end | |
| nil | |
| end | |
| def print *xs |