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
| fn request_start(self, head: Head, resp: &mut Response, scope: &mut Scope<C>) | |
| -> Option<Self> | |
| { | |
| res.status(hyper::status::StatusCode::Ok); | |
| res.add_header(TransferEncoding(vec![Encoding::Chunked]).unwrap(); | |
| res.done_headers().unwrap(); | |
| self | |
| } | |
| fn request_chunk(self, chunk: &[u8], resp: &mut Response, scope: &mut Scope<C>) | |
| -> Option<Self> |
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
| hyper mio 5747e07 | |
| tick 290af8617 | |
| > wrk -c 100 -d 60 -t2 http://localhost:3000 | |
| Running 1m test @ http://localhost:3000 | |
| 2 threads and 100 connections | |
| Thread Stats Avg Stdev Max +/- Stdev | |
| Latency 1.60ms 533.52us 19.86ms 96.35% | |
| Req/Sec 31.89k 4.17k 39.35k 62.83% | |
| 3808570 requests in 1.00m, 319.63MB read | |
| Requests/sec: 63450.68 |
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
| ./httpserver/samples/echo/echo_server -http_port 3000 -ip 127.0.0.1 -threads 1 | |
| proxygen a994f4a6f | |
| > wrk -c 100 -d 60 -t2 http://localhost:3000 | |
| Running 1m test @ http://localhost:3000 | |
| 2 threads and 100 connections | |
| Thread Stats Avg Stdev Max +/- Stdev | |
| Latency 3.53ms 588.05us 23.71ms 94.84% | |
| Req/Sec 14.28k 1.36k 16.88k 56.67% | |
| 1706482 requests in 1.00m, 182.27MB read | |
| Requests/sec: 28423.86 |
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
| let sink = loop_creator.add_and_fetch(identity, |scope| { | |
| connect_ip(addr, scope) | |
| }).unwrap(); |
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
| { | |
| let mut sender = sink.sender(); | |
| sender.add_value("metric.name1", 1); | |
| sender.add_value("metric.name2", 2.5); | |
| sender.add_value(format!("{prefix}.value", prefix="mymetrics"), 2.5); | |
| sender.add_value(format_args!("server.{}.value", servername), 12u32); | |
| } |
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
| with sink as sender: | |
| sender.add_value("metric.name1", value=1) | |
| sender.add_value("metric.name2", value=2.5) | |
| sender.add_value("{prefix}.value".format(prefix="mymetrics"), value=2.5) | |
| sender.add_value("server.{}.value", servername, value=12) |
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
| id = carbon_connect_ipv4((127 << 24) | (0 << 16) | (0 << 8) | (1 << 0), 2003) | |
| # then somewhere else | |
| carbon_add_i64(id, "metric.name1", len("metric.name1"), 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
| import random | |
| from time import sleep | |
| from stator import carbon | |
| def main(): | |
| carbon.init_env() | |
| while True: | |
| v1 = random.randrange(10, 100) | |
| v2 = random.randrange(100, 1000)/10.0 | |
| carbon.add("py.stator.random.int", v1) |
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
| # This is an pure-python alternative to stator's carbon implementation | |
| import os | |
| import random | |
| from time import sleep, time, clock | |
| from graphiti.client import Client | |
| def main(): | |
| carbon = Client(os.environ['CARBON_HOST']) | |
| while True: |
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
| from time import time, clock | |
| # .. later | |
| start = time() # clock() | |
| carbon.add("py.stator.random.int", v1) | |
| carbon.add("py.stator.random.float", v2) | |
| end = time() # clock() | |
| print(format(end - start, '0.5f')) |