🏋️♂️
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
func gravatarHash(email string) []byte { | |
return md5.Sum([]byte(email))[:] | |
} | |
func gravatarURL(hash [16]byte, size uint32) string { | |
return fmt.Sprintf("https://www.gravatar.com/avatar/%x?s=%d", hash, size) | |
} | |
func gravatar(email string, size uint32) string { | |
hash := gravatarHash(email) |
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 ( | |
+ context "golang.org/x/net/context" | |
+ grpc "google.golang.org/grpc" | |
+ ) | |
+ // Reference imports to suppress errors if they are not otherwise used. | |
+ var _ context.Context | |
+ var _ grpc.ClientConn | |
+ | |
+ // This is a compile-time assertion to ensure that this generated file |
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
syntax = "proto3"; | |
package gravatar; | |
service GravatarService { | |
rpc Generate(GravatarRequest) returns (GravatarResponse) | |
} | |
message GravatarRequest { | |
string email = 1; |
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
// Code generated by protoc-gen-go. DO NOT EDIT. | |
// source: gravatar.proto | |
package gravatar | |
import proto "github.com/golang/protobuf/proto" | |
import fmt "fmt" | |
import math "math" | |
// Reference imports to suppress errors if they are not otherwise used. |
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
alias Benchmarks.Util.Connection | |
conn = Connection.init!() | |
# ... | |
Benchee.run( | |
inputs: inputs, | |
before_scenario: fn inputs -> | |
Connection.reset!(conn) |
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
defmodule Benchmarks.Util.Connection do | |
alias EventStore.{Config, Storage.Initializer} | |
def init! do | |
with {:ok, conn} = | |
Config.parsed() | |
|> Config.default_postgrex_opts() | |
|> Postgrex.start_link() do | |
conn | |
end |
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
defmodule Util.Reset do | |
alias EventStore.{Config, Storage.Initializer} | |
def conn! do | |
{:ok, conn} = Config.parsed() |> Config.default_postgrex_opts() |> Postgrex.start_link() | |
conn | |
end | |
def do_reset!(conn) do | |
fn data -> |
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 Util.{Reset, Combinators} | |
# ... | |
conn = conn!() | |
Benchee.run( | |
# ... | |
time: 40, | |
warmup: 10, |
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
defmodule Util.Combinators do | |
def then(a, b) do | |
fn data -> b.(a.(data)) end | |
end | |
def a ~> b, do: a |> then(b) | |
end |
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
defmodule PostgresPubSub.Account do | |
use Ecto.Schema | |
@primary_key {:id, :binary_id, autogenerate: true} | |
schema "accounts" do | |
field(:username, :string) | |
end | |
end |