Swarming

HTML

<canvas id="canvas"></canvas>
<div id="output">
</div>
<div id="test"></div>

CSS

html, body{
    padding:0px;
    margin:0px;
    /*overflow:hidden;*/
    background-color:#000;
}
#canvas{
    width:100%;
    height:100%;
    background-color:#000;
    position:absolute;
    top:0px;
    left:0px;
}
#output{
    white-space:pre;
    font-family:monospace;
    font-size:12px;
    position:absolute;
    bottom:0px;
    left:0px;
    color:#a40;
}

JavaScript

//3D attempts
var O = (function() {
    var outputDiv = null;
    var setOutputDiv = function(id) {
        outputDiv = document.getElementById(id);
        outputDiv.firstChild.nodeValue = "";
    };

    var O = function(str) {
        outputDiv.firstChild.nodeValue += str;
    };

    var C = function() {
        outputDiv.firstChild.nodeValue = "";
    };

    return {
        O: O,
        S: setOutputDiv,
        C: C
    };
}());

var Profiler = (function() {
    var watches = {};
    var names = [];

    /**
     * @constructor
     */
    var Watch = function() {
        this.time = 0;
        this.updated = 0;
        this.s = null;
    };
    Watch.prototype.start = function() {
        this.s = Date.now();
    };
    Watch.prototype.stop = function() {
        this.time += Date.now() - this.s;
        this.updated++;
    };

    var addWatch = function(name) {
        watches[name] = new Watch();
        names.push(name);
    };

    var startWatch = function(name) {
        if (watches[name] === undefined) {
            addWatch(name);
        }
        watches[name].start();
    };

    var stopWatch = function(name) {
        watches[name].stop();
    };

    var getOutput = function() {
        var str = "";
        var totalTime = 0;
        var i = 0;
        for (i = 0; i < names.length; i++) {
            totalTime += watches[names[i]].time;
        }
        for (i = 0; i < names.length; i++) {
/*str+= "[" + 
               names[i] +":" +
               Math.floor(10000*watches[names[i]].time/totalTime)/100 +
               "]\n";*/
            str += "[" + names[i] + ": " + Math.floor(10000 * watches[names[i]].time / totalTime) / 100 + "%, " + Math.floor(
            1000 * 100 * watches[names[i]].time / watches[names[i]].updated) / 100 + "ms]\n";
        }

        return str;

    };

    return {
        add: addWatch,
        start: startWatch,
        end: stopWatch,
        output: getOutput
    };

}());

var Matrix = (function() {
 ...