Skip to content

Instantly share code, notes, and snippets.

View pfreixes's full-sized avatar

Pau Freixes pfreixes

  • Github
  • Barcelona
View GitHub Profile

Parsing many lines (lines 1000) (Repeated 10 times)

Time took Python json (Python version): 0.501879239018308

Time took cythonized Python json: 0.08349561202339828

Time took Python json (C version) : 0.05558486797963269

Time took ujson: 0.029640772991115227

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
An example client. Run simpleserv.py first before running this.
"""
from __future__ import print_function
from time import sleep
var net = require('net');
var sleep = require('sleep');
var client = new net.Socket();
client.connect(6379, '127.0.0.1', function() {
console.log('Connected');
sleep.sleep(10); // wait for data and RST package
});
client.on('data', function(data) {
import socket
import time
s = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 6379))
# give enought time to get the
# data plus the RST Package
time.sleep(1)
package test;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import java.nio.charset.Charset;
public class NettyTest {
public static void main(String[] args) throws Exception {
import aioredis
import asyncio
OPS = 100000
async def main(loop):
conn = await aioredis.create_redis(('localhost', 6379))
start = loop.time()
for i in range(OPS):
await conn.ping()
import asyncio
import time
async def coro():
await asyncio.sleep(0)
async def main(loop, coros):
start = loop.time()
for i in range(coros):
import asyncio
import time
import random
async def coro(loop, idx):
# distribute coros homogenity along 10 seconds
# to get a homogeneous traffic.
await asyncio.sleep(idx % 10)
if loop.load() > 0.9:
import asyncio
from aiohttp.signals import Signal
from unittest.mock import Mock
signal = Signal(Mock())
async def run_signal(loop, signals):
start = loop.time()
for i in range(signals):
from time import time
from blinker import signal
N = 1000000
test = signal('test')
start = time()
for i in range(N):
test.send()