Last active
February 14, 2017 03:39
-
-
Save temochka/4d73a20ef03d86666c13f5df804cedcc to your computer and use it in GitHub Desktop.
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 | |
require 'timeout' | |
abort "Usage: #{$0} <file> [duration] [rps]" unless ARGV.size >= 1 | |
filename, duration, rps = ARGV | |
duration = (duration || 5).to_i | |
rps = (rps || 100).to_i | |
pause = 1.0 / rps | |
reads = failures = 0 | |
endtime = Time.at(Time.now.to_i + duration) | |
while(Time.now < endtime) do | |
reads += 1 | |
File.mtime(filename) rescue failures += 1 | |
sleep pause | |
end | |
puts "Reads: #{reads}, Failures: #{failures}" | |
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/bash | |
swaps=1000 | |
mkdir -p releases1 releases2 | |
touch releases1/file releases2/file | |
rm -f releases | |
ln -s releases1 releases | |
################################################################################ | |
echo "# Switching symlinks via rm && ln -s" | |
./reader.rb releases/file $1 $2 & | |
reader_pid="$!" | |
for i in `seq $swaps` | |
do | |
rm -f releases | |
ln -s releases2 releases | |
rm -f releases | |
ln -s releases1 releases | |
done | |
wait $reader_pid | |
################################################################################ | |
echo "# Switching symlinks via ln -sf" | |
./reader.rb releases/file $1 $2 & | |
reader_pid="$!" | |
for i in `seq $swaps` | |
do | |
ln -sfT releases1 releases | |
ln -sfT releases2 releases | |
done | |
wait $reader_pid | |
################################################################################ | |
echo "# Switching symlinks via ln -s && mv" | |
./reader.rb releases/file $1 $2 & | |
reader_pid="$!" | |
for i in `seq $swaps` | |
do | |
ln -sfT releases2 releases_tmp | |
mv -T releases_tmp releases | |
ln -sfT releases1 releases_tmp | |
mv -T releases_tmp releases | |
done | |
wait $reader_pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment