Re: RE: RE: Groovy...competitive performance?
Ed,
Re: your points...noted and agreed.
But please understand that the loop in this script was tested on a 13 GByte
(with a G) text file. Any first pass issues are irrelevant.
Cheers
Edward Povazan wrote:
>
> A little off topic but on topic for benchmarks ...
> I've looked at some other benchmarks which rely on using command line
> commands to time a process etc. These are simply silly for the JVM.
> To make it fair, C benchmarks should be timed to include part of
> compile and link.
>
> In my own testing, I tend to create a benchmark method, and then call
> it repeatedly a few times before timing to warm up Hotspot. The
> difference between the first run or two and subsequent ones is huge.
> And of course the same will apply to Groovy. So any timing you get in
> a script written to execute once is suspect.
>
> -Ed
>
> On 27-Feb-07, at 5:24 AM, paduffy wrote:
>
>>
>> Here is the script. Appreciate it if you could point out any
>> glaring issues:
>>
>> // Various constants
>> //
>> inFileName = 'in.txt'
>> delim = '|'
>>
>> // Map input line prefix to output line params.
>> // Line param list format:
>> // [0] = name of outfile
>> // [1] = delim character
>> // [2] = number of delim chars required.
>>
>> fileParams =
>> [
>> 'A:' : ['a.txt', delim, 4],
>> 'B:' : ['b.txt', delim, 3],
>> 'C:' : ['c.txt', delim, 5],
>> 'D:' : ['d.txt', delim, 3],
>> 'E:' : ['e.txt', delim, 7],
>> 'F:' : ['f.txt', delim, 3],
>> 'G:' : ['g.txt', delim, 4],
>> 'H:' : ['h.txt', delim, 3],
>> 'I:' : ['i.txt', delim, 11],
>> 'J:' : ['j.txt', delim, 5],
>> 'K:' : ['k.txt', delim, 6],
>> 'L:' : ['l.txt', delim, 4],
>> 'M:' : ['m.txt', delim, 2]
>> ]
>>
>> startTime = System.currentTimeMillis()
>>
>> // Open all output files.
>> //
>> Map outStreams = [:]
>> fileParams.each
>> {
>> key, value ->
>> PrintWriter outStream = new File(value[0]).newPrintWriter()
>> outStreams[key] = outStream
>> }
>>
>> // Process the input file.
>> // Direct line to output file per line prefix.
>> //
>> File infile = new File(inFileName)
>> int lineCount = 0
>> for(line in infile)
>> {
>> // Print occasional activity status.
>> //
>> lineCount = lineCount + 1
>> if ((lineCount % 1000000) == 0) println "Processing line: $
>> {lineCount}"
>>
>> // Strip leading and trailing spaces.
>> // Ignore empty lines.
>> // Ignore comment lines
>> //
>> line = line.trim()
>> if (line == '') continue
>> if (line[0] == '#') continue
>>
>> // Split line into prefix and remainder.
>> //
>> String prefix = line.substring(0,2)
>> line = line.substring(2)
>>
>> if (outStreams[prefix])
>> {
>> outStreams[prefix].println(line)
>> }
>> }
>>
>> // Close all the output files.
>> //
>> outStreams.each { key, value -> value.close() }
>>
>> duration = System.currentTimeMillis() - startTime
>>
>> println ''
>> println "Processing finished, duration: ${duration} msec"
>> println ''
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
--
View this message in context: http://www.nabble.com/Groovy...competitive-performance--tf3298331.html#a9243702
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email