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
<%@ page language="java" contentType="text/html;charset=UTF-8" %> | |
<%@ page import="org.apache.log4j.Level" %> | |
<%@ page import="org.apache.log4j.LogManager" %> | |
<%@ page import="org.apache.log4j.Logger" %> | |
<%@ page import="java.util.HashMap" %> | |
<%@ page import="java.util.Enumeration" %> | |
<%@ page import="java.util.Set" %> | |
<%@ page import="java.util.Arrays" %> | |
<% | |
/* This was originally suggested by Nelz on http://nelz.net/2008/04/08/log4j-runtime-configuration */ |
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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
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
public final class Utils { | |
private Utils() { | |
} | |
public static void echo(String msg) { | |
System.out.println(msg); | |
} | |
public static void sleep(int millis) { |
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
package ru.int_overflow; | |
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.runner.Runner; | |
import org.openjdk.jmh.runner.RunnerException; | |
import org.openjdk.jmh.runner.options.Options; | |
import org.openjdk.jmh.runner.options.OptionsBuilder; | |
import java.util.concurrent.TimeUnit; |
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
package ru.int_overflow; | |
public class IntOverflowPuzzle { | |
// todo почему при использовании long разница в 1000 раз, действительно на столько медленнее | |
// todo почему при переполнении разница во времени в 1000 раз | |
private static void doOperation() { | |
// change type to long | |
// | |
// results: |
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
package ru; | |
// origin source: http://arhipov.blogspot.ru/2014/02/java-8-lambdas-unintentional-puzzle.html | |
// my gist with puzzle https://gist.github.com/iaveryanov/10990181 | |
public class Forrest { | |
public Runnable wrooom(){ | |
return new Runnable() { | |
@Override | |
public void run() { | |
System.out.println("Hello, lambda!"); |
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
package lambda.puzzle; | |
// source: http://arhipov.blogspot.ru/2014/02/java-8-lambdas-unintentional-puzzle.html | |
public class Forrest { | |
public Runnable wrooom(){ | |
return () -> { System.out.println("Hello, lambda!"); }; | |
} | |
public static void main(String[] args) { | |
Runnable runnable = new Forrest().wrooom(); |
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
package ru; | |
public interface InterfaceJava8 { | |
public static void main(String[] args) { | |
System.out.println("Hello from interface! It is java 8!"); | |
} | |
} |
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
package ru.inlinetelecom.vn2.util; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.concurrent.atomic.AtomicLong; | |
/** | |
* вариант с uncontended lock (getAvailableProcessors >= worker_count |
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
package ru.inlinetelecom.vn2.util; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.concurrent.atomic.AtomicLong; | |
/** | |
* вариант с uncontended lock (getAvailableProcessors >= worker_count |
NewerOlder