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
//Scala parallel version smallpt of http://www.cnblogs.com/miloyip/archive/2010/07/07/languages_brawl_GI.html | |
package parallel | |
class RandomLCG(var seed:Long) { | |
def nextDouble(): Double = { | |
seed = (214013L * seed + 2531011L) % 0x100000000L | |
seed * (1.0 / 4294967296.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
#!/usr/bin/env python | |
#coding=utf-8 | |
import stackless | |
import sys | |
import time | |
per_thread_requests = 10000 | |
def receive_task(): | |
for i in xrange(0, per_thread_requests): |
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 coroutine.kilim.benchmark; | |
import java.util.concurrent.CountDownLatch; | |
import kilim.Mailbox; | |
import kilim.Pausable; | |
import kilim.Task; | |
public class Main { |
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 scala.actors.{Actor} | |
import scala.actors.Actor._ | |
import java.util.concurrent.CountDownLatch | |
object Main { | |
val PROCESSER_COUNT=Runtime.getRuntime().availableProcessors() | |
var perThreadRequests=10000 | |
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
//From http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/bfd7abda8f79/src/share/classes/java/util/TimSort.java | |
/* | |
* Copyright 2009 Google Inc. All Rights Reserved. | |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
* | |
* This code is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License version 2 only, as | |
* published by the Free Software Foundation. Sun designates this | |
* particular file as subject to the "Classpath" exception as provided |
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
// Copyright 2009 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
package main | |
import "fmt" | |
// Send the sequence 2, 3, 4, ... to channel 'ch'. | |
func generate(ch chan int) { |
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
# 相比sieve.go,内存占用少很多哦 - 对比 http://gist.github.com/257036 | |
import stackless | |
def generate(channel): | |
i = 2 | |
while True: | |
channel.send(i) | |
i = i+1 | |
def filter_prime(in_chan, out_chan, prime): |
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 java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.UnsupportedEncodingException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import org.apache.commons.codec.binary.Base64; | |
/** |
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
/** | |
* 根据概率产生相应奖品 | |
* | |
* @return 相应对应的号码 | |
*/ | |
@SuppressWarnings("unchecked") | |
public static int getAward() { | |
Map result = new LinkedHashMap(); | |
for (int i = 0; i < 500; i++) { |
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
public <T extends Room> List<Integer> getBatchPlayerAmountOfRooms(List<T> rooms) { | |
if (rooms == null || rooms.size() == 0) | |
return new ArrayList<Integer>(0); | |
Collection<String> uidList = FPUtils.map(rooms, new FPUtils.MapFunc<T, String>() { | |
@Override | |
public String map(T room) { | |
return roomCacheKey(room); | |
} | |
}); |