Interesting. Here are the times I get:
LINUX:
slurp, *in* 18.8 seconds
slurp, System/in 18.2 seconds
slurp2, *in* 6.7 seconds
slurp2, System/in 5.7 seconds
I have an intel iMac here too, running 10.6.4:
slurp, *in* 20.4 seconds
slurp, System.in 19.0 seconds
slurp2, *in* 7.2 seconds
slurp2, System/in 6.0 seconds
For another data point, I wrote a simple java version:
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Cat {
public static void main(String[] args) throws Exception {
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
StringBuilder fileData = new StringBuilder();
char[] buffer = new char[4096];
int numRead = 0;
long totalRead = 0;
int c;
if (args[0].equals("single")) {
// single-char
read
while ((c = reader.read()) != -1) {
totalRead++;
fileData.append((char)c);
}
}
else {
// buffered
read
while ((numRead = reader.read(buffer)) != -1) {
totalRead += numRead;
fileData.append(buffer, 0, numRead);
}
System.out.println(totalRead);
}
}
}
Runnning this like so:
$ javac Cat.java && cat words | time java -Xmx3G -cp . Cat single
gives 14.5 seconds on linux and 17.1 seconds on the mac
running it like this:
$ javac Cat.java && cat words | time java -Xmx3G -cp . Cat buffered
gives 2.5 seconds on linux and 5.4 seconds on the mac
I'm not sure it's totally analogous but it does seem to indicate that
the single-char reads are slower on both platforms.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en