See the current amount of free and used memory in the system:
free -m
What actual time we have (in the console):
time = Benchmark.measure do
app.get '/needed-page'
end
puts time
See the current amount of free and used memory in the system:
free -m
What actual time we have (in the console):
time = Benchmark.measure do
app.get '/needed-page'
end
puts time
| # Test script to profile requests with GC options in case you have only access into the console. | |
| # | |
| # Invoke the script in the staging/production console: | |
| # | |
| # RAILS_ENV=production rails console | |
| # [1] pry(main)> load '/path/to/the-file/requests.rb' | |
| # | |
| # You will see benchmark results per link for analyzing. | |
| # | |
| # You should run it before and after changing GC options for comparison. |
| # Returns a number rounded to the desired multiple 0.5, | |
| # analog of excel's MROUND(A1, 0.05). | |
| def mround(number) | |
| (number * 20).round.to_f / 20 | |
| end |
| current_date=`date +%Y-%m-%d-%H:%M` | |
| file_name="db.$current_date.sql.gz" | |
| file_path="/mnt/backup/$file_name" | |
| mysqldump --single-transaction --quick -u*** -p*** DB | gzip -c > $file_name | |
| echo `ls -la $file_path` | mail -s "[backup] DB" admin@site.com |
| def fast_log_in | |
| user = Factory.create(:user) | |
| warden_key = User.serialize_into_session(user).unshift('User') | |
| page.set_rack_session(:'warden.user.user.key' => warden_key) | |
| user | |
| end |
| # Create the archive | |
| tar -zcvf archive.tar.gz /home/dir | |
| # Restore the archive | |
| tar -zxvf archive.tar.gz | |
| tar -zxvf archive.tar.gz -C /tmp |
| # http://www.fsarchiver.org/QuickStart | |
| sudo apt-get install fsarchiver | |
| # Find out what partition is used for the current folder and choose another partition for the dump | |
| df -h . | |
| df -h | |
| # Re-mount /dev/md2 partition to read only mode | |
| sudo mount -o remount,ro /dev/md2 | |
| sudo fsarchiver savefs ./ubuntu-md2.fsa /dev/md2 |
| // Enhanced and fixed the dequeue method | |
| if (first == null) return null; | |
| Object item = first.data; | |
| first = first.next; | |
| if (first == null) last = null; | |
| return item; |
| require 'minitest/autorun' | |
| class Towers | |
| class CantPlaceError < StandardError; end | |
| attr_accessor :from, :to | |
| def initialize(from, to) | |
| @from = from | |
| @to = to |