diff options
| author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 16:20:47 +0300 | 
|---|---|---|
| committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 16:20:47 +0300 | 
| commit | c13ee4fe746f4ba5fd48f926f3315284e66193f3 (patch) | |
| tree | 1e48e05c79120fb93cede2aa84a9cc59d8fb0fd8 | |
| parent | 40d0f1e1e3d7127ca36d5c91f80c90fb979ac6f4 (diff) | |
| download | radiorus-rss-c13ee4fe746f4ba5fd48f926f3315284e66193f3.tar.gz radiorus-rss-c13ee4fe746f4ba5fd48f926f3315284e66193f3.zip  | |
add benchmark
| -rw-r--r-- | main_test.go | 17 | 
1 files changed, 13 insertions, 4 deletions
diff --git a/main_test.go b/main_test.go index b3fbde4..fab7129 100644 --- a/main_test.go +++ b/main_test.go @@ -36,7 +36,7 @@ var (  const pth = "testdata/brand/57083" -func helperLoadBytes(t *testing.T, name string) []byte { +func helperLoadBytes(t testing.TB, name string) []byte {  	t.Helper()  	path := filepath.Join("testdata", name)  	bytes, err := ioutil.ReadFile(path) @@ -92,7 +92,16 @@ func TestServedFeed(t *testing.T) {  	}  } -func helperMockServer(t *testing.T) *httptest.Server { +func BenchmarkServedFeed(b *testing.B) { +	server := helperMockServer(b) +	defer helperCleanupServer(b) + +	for n := 0; n < b.N; n++ { +		processURL(fmt.Sprintf("%s/brand/57083/episodes", server.URL)) +	} +} + +func helperMockServer(t testing.TB) *httptest.Server {  	t.Helper()  	fileserver := http.FileServer(http.Dir("testdata")) @@ -107,13 +116,13 @@ func helperMockServer(t *testing.T) *httptest.Server {  	return server  } -func helperCleanupServer(t *testing.T) { +func helperCleanupServer(t testing.TB) {  	t.Helper()  	helperCleanupFile(t, "episodes")  	helperCleanupFile(t, "about")  } -func helperCleanupFile(t *testing.T, name string) { +func helperCleanupFile(t testing.TB, name string) {  	t.Helper()  	if err := os.Remove(filepath.Join(pth, name)); err != nil {  		t.Fatal(err)  |