Archived
14 lines
822 B
Python
14 lines
822 B
Python
import json, sys, time, urllib.request, threading
|
|
PORT=int(sys.argv[1])
|
|
def one(out):
|
|
body=json.dumps({"model":"qwen35","messages":[{"role":"user","content":"Write a detailed essay about the history of computing, covering many decades."}],"max_tokens":256,"temperature":0.7,"stream":False}).encode()
|
|
t0=time.time()
|
|
r=urllib.request.urlopen(urllib.request.Request(f"http://127.0.0.1:{PORT}/v1/chat/completions",data=body,headers={"Content-Type":"application/json"}),timeout=600).read()
|
|
out.append(json.loads(r)["usage"]["completion_tokens"]/(time.time()-t0))
|
|
for c in (1,4,8,16):
|
|
out=[]; th=[threading.Thread(target=one,args=(out,)) for _ in range(c)]
|
|
t0=time.time()
|
|
for t in th: t.start()
|
|
for t in th: t.join()
|
|
print(f"conc={c}: {sum(out):.1f} tok/s aggregate ({time.time()-t0:.0f}s)")
|