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
| (defn ping [] | |
| (:content (http/get "http://localhost:5123" :as :string))) | |
| (defn multi-ping [] | |
| (let [pings (repeatedly 16 #(ping))] | |
| (apply str pings))) |
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
| (defn par-ping [] | |
| (let [pings (repeatedly 16 #(future (ping)))] | |
| (apply str (pmap deref pings)))) |
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
| ;; ~450ms | |
| (dotimes [_ 10] | |
| (Thread/sleep 1000) | |
| (time | |
| (dotimes [_ 60] | |
| (multi-ping)))) | |
| ;; ~110ms | |
| (dotimes [_ 10] | |
| (Thread/sleep 1000) |
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
| var child_process = require('child_process'), | |
| sys = require('sys'), | |
| net = require('net'), | |
| netBinding = process.binding('net'); | |
| var fd = netBinding.socket('tcp4'); | |
| netBinding.bind(fd, 8080); | |
| netBinding.listen(fd, 128); | |
| for (var i = 0; i < 4; 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
| #!/bin/sh | |
| # change paths according to your repl setup | |
| USER_HOME="/Users/antonio.garrote" | |
| CLJR_HOME="/Users/antonio.garrote/.cljr" | |
| CLASSPATH=src:test:. | |
| if [ ! -n "$JVM_OPTS" ]; then | |
| JVM_OPTS="-Xmx1G" | |
| fi |
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
| var counter = 0; | |
| var server = require("http").createServer(function(request, response){ | |
| notifyOtherProcesses(); | |
| response.writeHead(200, {'Content-Type': 'text/plain'}); | |
| response.end('Hello multi-node!'+counter+'\n'); | |
| }); | |
| var nodes = require("multi-node").listen({ | |
| port: 8080, | |
| nodes: 8 | |
| }, server); |
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
| var counter = 0; | |
| var server = require("http").createServer( | |
| function(request, response){ | |
| counter++; | |
| notifyOtherProcesses(); | |
| response.writeHead(200, { | |
| 'Content-Type': 'text/plain' | |
| }); | |
| response.end('Hello multi-node! '+counter); | |
| } |
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
| (ns counter | |
| (:use aleph)) | |
| (def counter (atom 0)) | |
| (defn hello-world [request] | |
| (future | |
| (let [n (swap! counter inc)] | |
| (respond! request | |
| {:status 200 |
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
| var server = require("http").createServer(function(request, response){ | |
| response.writeHead(200, {'Content-Type': 'text/plain'}); | |
| response.end('Hello multi-node!\n'); | |
| }); | |
| var nodes = require("multi-node").listen({ | |
| port: 8080, | |
| nodes: 8 | |
| }, server); |
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
| var server = require("http").createServer( | |
| function(request, response){ | |
| response.writeHead(200, {'Content-Type': 'text/plain'}); | |
| response.end('Hello multi-node!\n'); | |
| } | |
| ); | |
| var nodes = require("multi-node").listen({ | |
| port: 8080, | |
| nodes: 8 | |
| }, server); |