Wednesday 7 April 2010

Extracting timings from Rails logs

Just a little tool to extract the timings for requests from the logs

#!/usr/bin/env ruby

ip_address = nil
datetime = nil

ARGV.each do |filename|
File.open(filename, "r").each do |line|
if line =~ /^Processing .*for ([\d\.]+) at (\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d)/
ip_address = $1
datetime = $2
elsif line =~ /^Completed in (\d+)ms .View: (\d+), DB: (\d+).*http(.*)\]/
puts "#{ip_address}\t#{datetime}\t#{$1}\t#{$2}\t#{$3}\thttp#{$4}"
end
end
end

Give it bunch of logs on the command line and it will output tab separated lines such as:

1.1.1.1 2010-04-05 04:03:03 7 1 4 http://www.example.com/fred

Where the values are as follows:

  1. The ip from which the request was made

  2. The data and time of the request

  3. The overall processing time in ms

  4. The ms timing for the view

  5. The ms timing for the db

  6. The requested url

Thursday 14 January 2010

Gamers and Programmers

I am a gamer. That is to say that for entertainment I play computer games the way other people watch TV or go to the cinema, I don't watch TV or go to the cinema.

I am also a programmer which means that the first two or three months of playing a new game involves trying to create a mental model of how the software works. More importantly I try to work out how I would create my own game. After returning to playing Civilisation IV I ended up with a half built system for a similar game.

I have recently started to play visual novels and I want to write my own. Which of course means writing my own engine :)

Which of course will have to be cross platform (including my iPod Touch) and I suspect will be in C++.

I already have a good idea as to where 2010 is going to go...