Thursday Nov 01, 2007
Thursday Nov 01, 2007
I wrote a simple ruby script to post process the allfrom.d output and generate a SVG image. The advantage of using SVG is that you can use javascript to provide added functionality. For example, you can hover your mouse over any block to see the name of the function and its elapsed time. Similarly, you could add support for Zoom and Pan
Unfortunately, I am having problems with blogs.sun.com serving svg files with the right mime type. So I have included a png image below. You can save the svg files somewhere on your computer and view them using Firefox.
A sample for the connect(3socket) is shown below. The input file used to generate it is available here. The width of each box indicates how long the function took. Y axis indicates call depth.

If you are interested, you can also check out
Thursday Oct 18, 2007
Rendering /tmp/neel/jruby-1.0.1/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/ action_controller/templates/rescues/layout.rhtml (500 Internal Error) no marshal_dump is defined for class Java::JavaObject /tmp/neel/jruby-1.0.1/lib/ruby/1.8/pstore.rb:349:in `dump' /tmp/neel/jruby-1.0.1/lib/ruby/1.8/pstore.rb:327:in `transaction' /tmp/neel/jruby-1.0.1/lib/ruby/1.8/cgi/session/pstore.rb:81:in `update' /tmp/neel/jruby-1.0.1/lib/ruby/1.8/cgi/session/pstore.rb:88:in `close' /tmp/neel/jruby-1.0.1/lib/ruby/1.8/cgi/session.rb:324:in `close'The problem is that Rails is trying to store the Java object in the session store. The default session store is the filesystem, and it fails since it cannot marshal a Java Object. Setting the session store to use memory instead of the filesystem solves the problem.
In config/environment.rb set
config.action_controller.session_store = :memory_store
Sunday Oct 14, 2007
Thursday Mar 22, 2007
require "java"
java.lang.Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance()
conn = java.sql.DriverManager.getConnection("jdbc:derby:test;create=true")
stmt = conn.createStatement
rs = stmt.executeQuery("select TABLEID,TABLENAME from sys.systables")
while (rs.next) do
printf("%20s %20s\n", rs.getString(1), rs.getString(2))
end
Wednesday Mar 07, 2007
#!/bin/env ruby -w
# Given an array, print it as a bar graph
# Use it at your own risk
class HorizBar
WIDTH = 72
HEIGHT = 16
def initialize(array)
@values = array
end
def draw
#Adjust X axis when there are more than WIDTH cols
if @values.length > WIDTH then
old_values = @values;
@values = []
0.upto(WIDTH - 1){ |i| @values << old_values[i*old_values.length/WIDTH]}
end
max = @values.max
# initialize display with blanks
display = Array.new(HEIGHT).collect { Array.new(WIDTH, ' ') }
@values.each_with_index do |e, i|
num= e*HEIGHT/max
(HEIGHT - 1).downto(HEIGHT - 1 - num){|j| display[j][i] = '|'}
end
display.each{|ar| ar.each{|e| putc e}; puts "\n"} #now print
end
end
# Sample usage 1
sample = [28829, 29095, 29301, 31827, 43478, 52937,62969]
HorizBar.new(sample).draw
# Another Sample usage
a = []
100.times { a << rand(100)}
HorizBar.new(a).draw
It produces output similar to
| | | | | | | | | | | | | | | | | || | | | | || | | || | | | || | | | | | || | | | || | | | | || || || | | | ||| | | | ||| || | | | || | || || | | || | ||| | | | ||| || | | | || | | || || | | | || || | ||| | | | ||| || | | | || | | || || | | | || || | ||| | | | | ||| || | | | || | | ||||| | | | || ||| | ||| | | ||| ||| || | | | || | || ||||| | | | || ||| | ||| | | ||||||||| || | || | || | || ||||| || || | | || ||| || ||| ||| ||||||||| || | || |||| | || ||||| || || | | || ||| || ||| ||| |||||||||| || || || | |||| | ||| ||||| |||||| || | || |||||| ||| ||| |||||||||| || || || |||||| | |||||| ||||| |||||| ||||||| |||||| ||| |||||||||||||| |||||||| |||||| | |||||| ||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rudimentary, but quite useful if you want to look at some data quickly.