evancz Mar 23, 2017 00:43
Just so folks are aware, one of the hard things about having ports just be a Task is the following. Right now, a Task is guaranteed to terminate with an error or a result.
The only way it could be otherwise is if you have something of type Task Never Never
Now, if you are calling out to random JS that is written by anyone, that guarantee goes away.
You have to call some callback to give the value back to Elm, but what if that is never called?
Maybe there's an error, maybe there is a weird code path.
Now Elm code can "leak" tasks that never get completed because of problems in JS code.
One way to protect against this is to have timeouts, such that there is some guaranteed end.
My point here is just that it is more complicated than "what if it was a task?" and then everything would be nice.
type StackOps<S, A> = { | |
init(): S | |
push(s: S, x: A): void | |
pop(s: S): A | |
size(s: S): number | |
} | |
type Stack<A> = <R>(go: <S>(ops: StackOps<S, A>) => R) => R | |
const arrayStack = <A>(): Stack<A> => |
# From the ACR 2016 coding challenge. | |
defmodule SnakeCase do | |
@doc """ | |
Brute force, single process. | |
""" | |
def single do | |
range = 0..round(:math.pow(2, 20)) | |
count = Enum.count(range, fn x -> check_one_bits(x) == 10 end) |
I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.
Framework | Throughput (req/s) | Latency (ms) | Consistency (σ ms) |
---|
digraph widening { | |
node [style=filled, colorscheme=pastel13, color=2] "i8"; "i16"; "i32"; "i64"; | |
node [style=filled, colorscheme=pastel13, color=3] "u8"; "u16"; "u32"; "u64"; | |
"i8" -> "i16" | |
"i8" -> "i32" | |
"i8" -> "i64" | |
"i16" -> "i32" | |
"i16" -> "i64" | |
"i32" -> "i64" |
Alien = class() | |
-- Free game by juaxix | |
-- http://www.xixgames.com | |
-- Copyright LGPL - 11/2011 | |
function Alien:init(avoidy) | |
self.position = vec2(0,math.max(math.abs(math.random(HEIGHT)-avoidy)),66) | |
self.angle = math.pi | |
self.points= 500 | |
end |
import System.Directory | |
import System.Environment | |
import System.FilePath | |
import Control.Applicative ((<$>)) | |
import Control.Arrow (first, second) | |
import Control.Monad (void) | |
import Data.Either (rights) | |
import Data.List (isSuffixOf) | |
import Data.Set (Set, (\\), empty, fromList, insert, singleton, toList, union) | |
import Text.Parsec |
//! Chain macro in Rust | |
//! | |
//! A typical usage is to avoid nested match expressions. | |
//! | |
//! Supports: | |
//! - Pattern matching | |
//! - Or expressions (A | B => ...) | |
//! - Guarded statements (x if <cond> => ...) | |
//! - Implicit else (requires all arms to return same type) |
EX="" | |
EX+=" --exclude=.DS_Store" | |
EX+=" --exclude=/iBooks.app/" | |
EX+=" --exclude=/iTunes.app/" | |
EX+=" --exclude=/FaceTime.app/" | |
EX+=" --exclude=/Calendar.app/" | |
EX+=" --exclude=/Mail.app/" | |
EX+=" --exclude=/QuickTime?Player.app/" | |
EX+=" --exclude=/Safari.app/" | |
EX+=" --exclude=/Preview.app/" |
There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.
So, these are the different settings we are going to compare:
- Go HTTP standalone (as the control group)
- Nginx proxy to Go HTTP
- Nginx fastcgi to Go TCP FastCGI
- Nginx fastcgi to Go Unix Socket FastCGI