Small modifications

This commit is contained in:
Ben Sarmiento
2023-11-29 00:44:57 +01:00
parent 1120ada9af
commit 7badbc50dc
3 changed files with 16 additions and 11 deletions

View File

@@ -11,20 +11,21 @@ async def extract_links(url):
for link in soup.find_all('a'):
yield urljoin(url, link.get('href'))
async def benchmark(url):
# This will still block, because subprocess.run is not async
subprocess.run(['hey', '-n', '100', '-c', '10', url])
subprocess.run(['hey', '-n', '10000', '-c', '100', url])
url = 'http://zen.box:9999/http/'
url = 'http://localhost:9999/http/'
async def main():
i = 1
async for link in extract_links(url):
if i > 50:
break
await benchmark(link)
print("BENCHMARKING " + link.replace('/http/', '/'))
await benchmark(link.replace('/http/', '/'))
i += 1
print("BENCHMARKING " + link)
await benchmark(link)
# Python 3.7+
asyncio.run(main())

View File

@@ -76,7 +76,7 @@ func handleListTorrents(w http.ResponseWriter, requestPath string, t *torrent.To
}
resp, _ := t.ResponseCache.Get(basePath + ".dav")
davDoc := "<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">" + dav.BaseDirectory(basePath, "") + dav.BaseDirectory(basePath, "") + resp.(string) + "</d:multistatus>"
davDoc := resp.(string)
return &davDoc, nil
}

View File

@@ -899,10 +899,14 @@ func (t *TorrentManager) updateSortedKeys() {
continue
}
davRet += dav.Directory(tor.AccessKey, tor.LatestAdded)
htmlRet += fmt.Sprintf("<a href=\"/%s/%s\">%s</a><br>", directory, tor.AccessKey, tor.AccessKey)
htmlRet += fmt.Sprintf("<li><a href=\"/%s/%s\">%s</a></li>", directory, tor.AccessKey, tor.AccessKey)
}
}
t.ResponseCache.Set(directory+".dav", davRet, 1)
t.ResponseCache.Set(directory+".html", "<ol>"+htmlRet, 1)
davRet = "<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">" + dav.BaseDirectory(directory, "") + dav.BaseDirectory(directory, "") + davRet + "</d:multistatus>"
t.ResponseCache.Set(directory+".dav", davRet, 0)
htmlRet = "<ol>" + htmlRet
t.ResponseCache.Set(directory+".html", "<ol>"+htmlRet, 0)
})
}