Skip to content

Instantly share code, notes, and snippets.

@jmcguirk
jmcguirk / app.go
Created November 15, 2012 18:51
GO Game workload Benchmark
package main
import (
"fmt"
"net/http"
"log"
"redis"
"runtime"
"encoding/json"
"compress/zlib"
@jmcguirk
jmcguirk / 100 Concs
Created November 16, 2012 17:38
VS Benchmark revised
Concurrency Level: 100
Time taken for tests: 6.262829 seconds
Complete requests: 10000
/***********************************************************
Failed requests: 5028
(Connect: 0, Length: 5028, Exceptions: 0)
@jmcguirk
jmcguirk / app.go
Created November 16, 2012 18:16
V3 Go Benchmark
package main
import (
"bytes"
"compress/zlib"
"encoding/json"
"fmt"
"log"
"math"
"net/http"
/**
* Appends a new item into the given users inbox
*
* @param userId The recipient of this message
* @param listName The name of the list being processed
* @param data The data to include with this message
* @param callback The callback to make when the list is fully processed. Passes error indicator and a buffer
*/
this.appendInboxItem = function(userId, listName, data, callback){
var client = this._getClientForKey(userId);
/**
* Gets a collection of new inbox items, if any
*
* @param userId The user id of the user whos list is being processed
* @param listName The name of the list being processed
* @param playerInbox The players current inbox
* @param callback The callback to make when the list is fully processed. Passes error indic
*/
this.getNewInboxItems = function(userId, listName, playerInbox, callback){
var client = this._getClientForKey(userId);
/**
* Acks all outstanding inbox messages
*
* @param userId The user id of the user whos list is being processed
* @param listName The name of the list being processed
* @param playerInbox The players current inbox
* @param callback The callback to make when the list is fully processed. Passes error indic
*/
this.ackInboxItems = function(userId, listName, playerInbox, callback){
this.ackInboxItemNext(userId, listName, playerInbox, 0, callback);
/**
* Prune any inbox items that need to be deleted
*
* @param playerInbox the inbox to prune from
*/
this.pruneReceivedInboxItems = function(playerInbox){
var now = new Date().getTime();
for(var messageId in playerInbox){
var nextMessage = playerInbox[messageId];
var age = now - nextMessage.receivedOn;
/*!
* Inbox service. Responsible for sending messages and receiving new ones
*/
function InboxService(){
this.fetchNewItems = function(args, context, callback){
var callResponse = {};
ServiceLocator.PlayerManager.getOrCreatePlayer(context.UserId, context, function(player){
protected function wtf():void{
var val:int = -3;
switch(val){
case -3:
trace("woohoo");
break;
default:
trace('wtf!');
break;
}
protected function works():void{
var val:int = 3;
switch(val){
case 3:
trace("woohoo");
break;
default:
trace('wtf!');
break;
}