$ GOMAXPROCS=1 ./stress
GET Test results
Ops/sec: 100015
P50: 0.000304 seconds
P99: 0.000825 seconds
SET Test results
This file contains 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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"os" | |
"sync" | |
"time" | |
) |
This file contains 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
TAXA_DE_MULTIPLICACIO = 3 | |
PERCENTATGE_DE_HOSPITALITZATS = 20 | |
casos_reportats = [18, 28, 32, 45, 48, 77, 100, 124, 181, 319, 509, 715, 903, 1394] | |
casos_reals = casos_reportats[0] | |
for i in range(1, len(casos_reportats)): | |
casos_reals += ((casos_reportats[i] - casos_reportats[i-1]) * 100 / PERCENTATGE_DE_HOSPITALITZATS) * TAXA_DE_MULTIPLICACIO | |
print(casos_reals) |
This file contains 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 asyncio | |
import grpc | |
from grpc.experimental import aio | |
from proto import echo_pb2 | |
from proto import echo_pb2_grpc | |
async def run_sync_request(loop): |
This file contains 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 time | |
N = 1000000 | |
def benchmark(): | |
l = None | |
start = time.time() | |
for i in range(N): | |
if l: | |
pass |
This file contains 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 asyncio | |
import pytest | |
import subprocess | |
import time | |
from grpc_asyncio import grpc_init_asyncio | |
from grpc_asyncio import create_channel | |
from tests.acceptance.fixtures import echo_pb2 |
This file contains 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
$ python | |
Python 3.7.2 (default, Jan 13 2019, 12:51:54) | |
[Clang 9.0.0 (clang-900.0.39.2)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> dir() | |
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__'] | |
>>> f = [1, 2, 3] | |
>>> dir() | |
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f'] | |
>>> for x in f: |
This file contains 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 = "proto2"; | |
package tutorial; | |
message Person { | |
required string name = 1; | |
required int32 id = 2; | |
optional string email = 3; | |
enum PhoneType { |
This file contains 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
>>> timeit.timeit("""json.dumps({"name": "foo", "id":1})""", setup="from __main__ import json", number=10000) | |
0.04011281501152553 | |
>>> timeit.timeit("json_format.MessageToJson(person)", setup="from __main__ import json_format, person", number=10000) | |
0.2599130409944337 | |
>>> person | |
name: "foo" | |
id: 1 |
This file contains 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 asyncio | |
import contextvars | |
import uvloop | |
from types import SimpleNamespace | |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) | |
trace_context = contextvars.ContextVar('trace_context') | |
NewerOlder