# File lib/railsbench/perf_utils.rb, line 55
def truncate(text, length = 32, truncate_string = "...")
  if text.nil? then return "" end
  l = truncate_string.length + 1

  if $KCODE == "NONE"
    text.length > length ? text[0..(length - l)] + truncate_string : text
  else
    chars = text.split(//)
    chars.length > length ? chars[0..(length - l)].join + truncate_string : text
  end
end