This file contains hidden or 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
Compiled from "Test.java" | |
public class Test { | |
public Test(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: return | |
public void testA(); | |
Code: |
This file contains hidden or 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 org.sample; | |
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 hidden or 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 org.sample; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.lang.reflect.Field; | |
public class MyBenchmark { | |
@Benchmark |
This file contains hidden or 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 org.sample; | |
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; | |
import java.util.regex.Pattern; |
This file contains hidden or 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 org.sample; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Fork; | |
import org.openjdk.jmh.infra.Blackhole; | |
public class MyBenchmark { | |
private static final String[] EMPTY_STRING_ARRAY = new String[0]; |
This file contains hidden or 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
Thu Jun 8 18:42 2017 Time and Allocation Profiling Report (Final) | |
10 +RTS -p -RTS | |
total time = 7.79 secs (7786 ticks @ 1000 us, 1 processor) | |
total alloc = 6,259,859,408 bytes (excludes profiling overheads) | |
COST CENTRE MODULE %time %alloc | |
p.sieve.update.decrease Main 52.2 67.5 |
This file contains hidden or 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 Data.List | |
import Data.IntMap (IntMap, (!)) | |
import qualified Data.IntMap as IntMap | |
p :: Int -> Int | |
p n = (sieve (IntMap.fromList [(i, i * (i + 1) `div` 2 - 1) | i <- vs]) 2 r vs) ! n | |
where vs = [n `div` i | i <- [1..r]] ++ reverse [1..n `div` r - 1] | |
r = floor (sqrt (fromIntegral n)) |
This file contains hidden or 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 Data.List | |
import Data.IntMap.Strict(IntMap, (!)) | |
import qualified Data.IntMap.Strict as IntMap | |
problem10 :: Int -> Int | |
problem10 n = (sieve (IntMap.fromList [(i, i * (i + 1) `div` 2 - 1) | i <- vs]) 2 r vs) ! n | |
where vs = [n `div` i | i <- [1..r]] ++ [n', n' - 1 .. 1] | |
r = floor (sqrt (fromIntegral n)) | |
n' = n `div` r - 1 |
This file contains hidden or 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 Data.List | |
import qualified Data.HashTable.IO as H | |
import Data.Maybe (fromJust) | |
type HashTable k v = H.BasicHashTable k v | |
(!) :: IO (HashTable Int Int) -> Int -> IO Int | |
(!) m k = do | |
h <- m | |
x <- H.lookup h k |
This file contains hidden or 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
/* | |
Compile: | |
g++ -O2 --std=c++11 10.cpp | |
Run: | |
time ./a.out | |
Results with g++ version 4.8.4: | |
sum(20000000) = 12272577818052 in 0.019s | |
sum(200000000) = 1075207199997334 in 0.063s |
OlderNewer