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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func Calculate(x, y int64) int64 { | |
// get random integer between 0 and 100 |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
"net/http" | |
"net/http/httptest" | |
"testing" | |
) |
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
package main | |
import ( | |
"encoding/json" | |
"net/http" | |
"strconv" | |
) | |
type Response struct { | |
Message string `json:"message"` |
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
package main | |
import ( | |
"log" | |
"testing" | |
) | |
// You can use testing.T, if you want to test the code without benchmarking | |
func setupSuite(tb testing.TB) func(tb testing.TB) { | |
log.Println("setup suite") |
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
package main | |
import "testing" | |
func TestDoubleMe(t *testing.T) { | |
table := []struct { | |
input float64 | |
expected float64 | |
}{ | |
{1, 2}, |
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
package main | |
import ( | |
"fmt" | |
) | |
func doubleMe(x float64) float64 { | |
return x * 2 | |
} |
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
version: '3' | |
services: | |
master: | |
image: locustio/locust | |
ports: | |
- "8089:8089" | |
volumes: | |
- ./:/mnt/locust | |
command: -f /mnt/locust/main.py --master -H http://master:8089 |
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 time | |
import random | |
import gevent | |
from locust import HttpUser, task, between, TaskSet, events | |
from locust.runners import STATE_STOPPING, STATE_STOPPED, STATE_CLEANUP, WorkerRunner | |
def fast_task(user): | |
user.client.get('/fast', headers={'login-token': user.login_token}) |
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 time | |
import uvicorn | |
from typing import List | |
from pydantic import BaseModel | |
from fastapi import FastAPI, Header, HTTPException, Depends | |
app = FastAPI() | |
@app.get('/hello') |
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 locust import HttpUser, task, between | |
class HelloWorldUser(HttpUser): | |
wait_time = between(0.5, 2.5) | |
@task | |
def hello_world(self): | |
self.client.get('/hello') |