Programming Tutorials

ruby Tutorials

31. Benchmark module in Ruby

By: Emiley J. : 2009-03-03

Description: The Benchmark module provides methods to measure and report the time used to execute Ruby code.


32. benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby

By: Jeya : 2009-03-03

Description: Invokes the block with a Benchmark::Report object, which may be used to collect and report on the results of individual benchmark tests. Reserves label_width leading spaces for labels on each line. Prints caption at the top of the report, and uses fmt to format each line. If the block returns an array of Benchmark::Tms objects, these will be used to format additional lines of output. If label parameters are given, these are used to label these extra lines.


33. bm(label_width = 0, *labels) {|report| ...} in Ruby

By: Jeya : 2009-03-03

Description: A simple interface to the benchmark method, bm is generates sequential reports with labels. The parameters have the same meaning as for benchmark.


34. bmbm(width = 0) {|job| ...} in Ruby

By: Jeya : 2009-03-03

Description: Sometimes benchmark results are skewed because code executed earlier encounters different garbage collection overheads than that run later. bmbm attempts to minimize this effect by running the tests twice, the first time as a rehearsal in order to get the runtime environment stable, the second time for real. GC.start is executed before the start of each of the real timings; the cost of this is not included in the timings. In reality, though, there's only so much that bmbm can do, and the results are not guaranteed to be isolated from garbage collection and other effects.


35. CGI class in Ruby

By: Jeeva : 2009-03-03

Description: CGI is a large class, providing several categories of methods, many of which are mixed in from other modules. Some of the documentation is in this class, some in the modules CGI::QueryExtension and CGI::HtmlExtension. CGI::Cookie handles cookies.


36. URL encode a string in Ruby

By: Jeeva : 2009-03-03

Description: URL-encode a string.


37. escapeElement() in Ruby

By: Jeeva : 2009-03-03

Description: Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, the double-quotes surrounding attribute values).


38. escapeHTML() in Ruby

By: Jeeva : 2009-03-03

Description: Escape special characters in HTML


39. new(type = "query") in Ruby

By: Jeeva : 2009-03-03

Description: If the CGI object is not created in a standard CGI call environment (that is, it can't locate REQUEST_METHOD in its environment), then it will run in "offline" mode. In this mode, it reads its parameters from the command line or (failing that) from standard input. Otherwise, cookies and other parameters are parsed automatically from the standard CGI locations, which varies according to the REQUEST_METHOD.


40. parse(query) in Ruby

By: Jeeva : 2009-03-03

Description: Parse an HTTP query string into a hash of key=>value pairs.