Skip to content

Instantly share code, notes, and snippets.

@brawer
brawer / wikidata_redirects.py
Created September 26, 2022 14:56
query Wikidata redirects
import re, requests
def _query(query):
r = requests.post('https://query.wikidata.org/sparql',
params={'query': query},
headers={'Accept': 'text/tab-separated-values'})
return r.text.splitlines()
_entity_re = re.compile(r'^<http://www.wikidata.org/entity/([A-Z]\d+)>$')
@brawer
brawer / loadtest.py
Last active April 15, 2019 08:18
Loadtest with Vegeta
# Script for loadtesting a server with https://github.com/tsenart/vegeta
#
# Sample output. The server under test breaks down at 10k queries per second:
# its error rate goes from 0% to 23%, its 99th latency percentile goes
# from 0.488 milliseconds (at 1000 qps) to 71.18 ms (at 10000 qps).
#
# qps errors 50th 95th 99th
# 1000 0.0 0.182 0.222 0.488
# 2000 0.0 0.144 0.224 0.431
# 3000 0.0 0.141 0.244 0.466