I’m issuing random timouts on java8 streams on the code4life contest.
The lists are max 3 element size.
Does anyone have the same issue? If so is there any solution to fix ?
Im not getting the “Change to C++” or the “Go back to for loop” as serious solutions
When you have a timeout it doesn’t always mean that code is slow, but just that you have not provided anything in time, so double-ckeck that you don’t have a branch when no output is printed.
I already encountered timeouts with streams and java 8.
I don’t know why, but the FIRST execution of a stream can take a long time. I workaround the issue on other contest by simply ensuring the streams are used at least once during the first turn with a dummy code. such as:
public Player(){
List warmup = Arrays.asList(“toto”, “tata”);
warmup.stream().min((s1, s2)-> Integer.compare(s1.length(), s2.length())).get();
}
We can achieve both of these goals by using the invokedynamic feature from JSR 292 to separate the binary representation of lambda creation in the bytecode from the mechanics of evaluating the lambda expression at runtime. Instead of generating bytecode to create the object that implements the lambda expression (such as calling a constructor for an inner class), we describe a recipe for constructing the lambda, and delegate the actual construction to the language runtime.
So looks like lambda is constructed in runtime (during the first call?)