Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
api: Added benchmark tests
Browse files Browse the repository at this point in the history
Benchmark tests use the Benchmark facility to evaluate performance of the code.
  • Loading branch information
Nyah Check committed Sep 17, 2017
1 parent be23709 commit fde5efc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ lint:
test: fmt lint vet
@echo "+ $@"
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list ./... | grep -v vendor)
@go test -bench=. $(shell go list ./... | grep -v vendor)

vet:
@echo "+ $@"
Expand Down
31 changes: 27 additions & 4 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ var tables = []struct {
{"https://vimeo.com/101522071", ""},
}

var vid []string

func TestApi(t *testing.T) {

path := "~/Downloads/"
//path := "~/Downloads/"
for i, table := range tables {
var rawVideo *RawVideoData
ID, _ := GetVideoId(table.url)
Expand All @@ -34,16 +36,37 @@ func TestApi(t *testing.T) {
}

if ID != "" {
video, err := APIGetVideoStream(ID, rawVideo)
_ , err := APIGetVideoStream(ID, rawVideo)
if err != nil {
t.Errorf("APIGetVideoStream(%d): expected %v, actual %v", i, nil, err)
}

file := path + table.url + ".mp3"
/*file := path + table.id + ".mp3"
err = APIConvertVideo(file, 123, ID, video)
if err != nil {
t.Errorf("APIConvertVideo(%d): expected %v, actual %v", i, nil, err)
}
}*/
}
}
}

func BenchmarkGetVideoId(b *testing.B) {
for n := 0; n < b.N; n++ {
GetVideoId(tables[0].url)
}
}

func BenchmarkApiGetVideoStream(b *testing.B) {
for n := 0; n < b.N; n++ {
var rawVideo *RawVideoData
vid, _ = APIGetVideoStream(tables[0].id, rawVideo)
}
}
/*
func benchmarkApiConvertVideo(b *testing.B) {
path := "~/Downloads/"
for n := 0; n < b.N; n++ {
file := path + tables[0].id + ".mp3"
APIConvertVideo(file, 123,tables[0].id, vid)
}
} */

0 comments on commit fde5efc

Please sign in to comment.