benchmarks refreshed
This commit is contained in:
+1
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package binary_trees;
|
||||
|
||||
public class BinaryTrees {
|
||||
|
||||
+17
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package binary_trees;
|
||||
|
||||
val minDepth = 4
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package flist;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
abstract public class FList<T> {
|
||||
@@ -1,4 +1,19 @@
|
||||
package flist
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package flist_kotlin
|
||||
|
||||
abstract class FList<T> {
|
||||
abstract val head : T
|
||||
@@ -7,7 +22,7 @@ abstract class FList<T> {
|
||||
abstract fun plus(element: T) : FList<T>
|
||||
}
|
||||
|
||||
class EmptyFList<T>() : FList<T> {
|
||||
class EmptyFList<T>() : FList<T>() {
|
||||
override val head: T
|
||||
get() = throw java.util.NoSuchElementException()
|
||||
|
||||
@@ -17,14 +32,14 @@ class EmptyFList<T>() : FList<T> {
|
||||
override fun plus(element: T) : FList<T> = OneElementFList<T>(element)
|
||||
}
|
||||
|
||||
class OneElementFList<T> (override val head: T): FList<T> {
|
||||
class OneElementFList<T> (override val head: T): FList<T>() {
|
||||
override val tail : EmptyFList<T>
|
||||
get() = EmptyFList<T>()
|
||||
|
||||
override fun plus(element: T) : FList<T> = StandardFList<T>(element, this)
|
||||
}
|
||||
|
||||
class StandardFList<T> (override val head: T, override val tail: FList<T>) : FList<T> {
|
||||
class StandardFList<T> (override val head: T, override val tail: FList<T>) : FList<T>() {
|
||||
override fun plus(element: T) : FList<T> = StandardFList<T>(element, this)
|
||||
}
|
||||
|
||||
+2
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package lockperf;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
+20
-7
@@ -1,4 +1,20 @@
|
||||
package lockperformance
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package lockperf_kotlin
|
||||
|
||||
import std.io.*
|
||||
import std.util.*
|
||||
@@ -30,10 +46,10 @@ fun main(args: Array<String>) {
|
||||
lock.lock()
|
||||
try {
|
||||
if (counter.get() == 100000000) {
|
||||
countDown();
|
||||
countDown()
|
||||
break;
|
||||
} else {
|
||||
counter.incrementAndGet();
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -47,9 +63,6 @@ fun main(args: Array<String>) {
|
||||
|
||||
println(threadNum.toString() + " " + duration)
|
||||
|
||||
if(threadNum < 2 * processors)
|
||||
threadNum = threadNum + 1
|
||||
else
|
||||
threadNum = threadNum * 2
|
||||
if(threadNum < 2 * processors) threadNum++ else threadNum = 2*threadNum
|
||||
}
|
||||
}
|
||||
+2
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package quicksort;
|
||||
|
||||
public class Quicksort {
|
||||
|
||||
public static void swap(int[] a, int i, int j) {
|
||||
+16
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package quicksort
|
||||
|
||||
fun IntArray.swap(i:Int, j:Int) {
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
package spectralnorm_kotlin;
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package spectralnorm
|
||||
package spectralnorm_kotlin
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
+1
-16
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package threadring;
|
||||
/**
|
||||
* The Computer Language Benchmarks Game
|
||||
* http://shootout.alioth.debian.org/
|
||||
+20
-8
@@ -1,4 +1,20 @@
|
||||
package threadring
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package threadring_kotlin
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
@@ -24,19 +40,14 @@ fun main(args: Array<String>) {
|
||||
System.out?.println("[ThreadRing-" + System.getProperty("project.name")+ " Benchmark Result: " + total + "]")
|
||||
}
|
||||
|
||||
class TokenMessage(val nodeId : Int, value: Int, val isStop: Boolean) : AtomicInteger(value){
|
||||
}
|
||||
class TokenMessage(val nodeId : Int, value: Int, val isStop: Boolean) : AtomicInteger(value)
|
||||
|
||||
class ThreadRing(val N: Int) {
|
||||
val executor = Executors.newFixedThreadPool(MAX_THREADS).sure()
|
||||
|
||||
val nodes : Array<Node> = Array<Node>(MAX_NODES+1, { Node(it+1) })
|
||||
val nodes : Array<Node> = Array<Node>(MAX_NODES+1, { (it : Int) -> Node(it+1) });
|
||||
|
||||
{
|
||||
connectNodes()
|
||||
}
|
||||
|
||||
fun connectNodes() {
|
||||
nodes[nodes.size-1] = nodes[0]
|
||||
for (i in 0..nodes.size-2) {
|
||||
nodes[i].connect(nodes[i+1]);
|
||||
@@ -46,6 +57,7 @@ class ThreadRing(val N: Int) {
|
||||
fun sendMessage(m : TokenMessage) {
|
||||
nodes[0].sendMessage(m)
|
||||
}
|
||||
|
||||
class Node(val nodeId : Int) : Runnable {
|
||||
val queue = LinkedBlockingQueue<TokenMessage>()
|
||||
var isActive = false
|
||||
Reference in New Issue
Block a user