This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patched bench file from master running without fix | |
# jruby-2810 patch contains fixes to benchmarks & code changes. | |
# Mine was screwy because of bench file changing when I applied patch (not apples to apples) | |
rj-lorimers-macbook-pro:bench rjlorimer$ ../bin/jruby --server bench_io_foreach.rb | |
user system total real | |
IO.foreach(file) 15.171000 0.000000 15.171000 ( 15.107000) | |
user system total real | |
IO.foreach(file) 13.667000 0.000000 13.667000 ( 13.667000) | |
user system total real | |
IO.foreach(file) 13.144000 0.000000 13.144000 ( 13.144000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With JRUBY-1.5.0-DEV, no patches: | |
rj-lorimers-macbook-pro:bench rjlorimer$ ../bin/jruby --server bench_io_foreach.rb | |
user system total real | |
IO.foreach(file) 15.171000 0.000000 15.171000 ( 15.107000) | |
user system total real | |
IO.foreach(file) 13.667000 0.000000 13.667000 ( 13.667000) | |
user system total real | |
IO.foreach(file) 13.144000 0.000000 13.144000 ( 13.144000) | |
user system total real | |
IO.foreach(file) 14.110000 0.000000 14.110000 ( 14.110000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static spark.Spark.*; | |
import spark.*; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
get(new Route("/hello") { | |
@Override | |
public Object handle(Request request, Response response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
File.open("myInput.txt", "r") do |in| | |
File.open("myOutput.txt", "w") do |out| | |
in.each_line do |line| | |
out << line.upcase << "\n" | |
end | |
end | |
end | |
rescue exc | |
# Exception occurred reading/writing! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
File.read("myInput.txt", #{ in -> | |
File.write("myOutput.txt", #{ out -> | |
in.eachLine( #{ line -> | |
out.write(line.toUpperCase() + "\n"); | |
}); | |
}); | |
}); | |
} | |
catch(IOException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InputStream in; | |
try { | |
in = loadInput(...); | |
OutputStream out; | |
try { | |
out = createOutput(...); | |
copy(in, out); | |
} | |
finally { | |
if(out != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(String line : in.eachLine()) { | |
out.write(line.toUpperCase() + "\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try (InputStream in = loadInput(...); | |
OutputStream out = createOutput(...) ){ | |
copy(in, out); | |
} | |
catch (Exception e) { | |
// Problem reading and writing streams. | |
// Or problem opening one of them. | |
// If compound error closing streams occurs, it will be recorded on this exception | |
// as a "suppressedException". | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HashMap<String,String> myMap = new HashMap<String,String>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typer = Typer.new | |
asts.each { |ast| typer.infer(ast) } | |
typer.resolve |
OlderNewer