Skip to content

Commit

Permalink
- add benchmark
Browse files Browse the repository at this point in the history
- update problems-store dependency
- cleanup
  • Loading branch information
spolnik committed Oct 2, 2018
1 parent 4fc5a78 commit 96a47ca
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[[constraint]]
name = "github.com/jalgoarena/problems-store"
version = "1.0.3"
version = "1.0.4"

[prune]
go-tests = true
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func GetSkeletonCode(c *gin.Context) {
return problem.Id == problemId
})

sourceCode, err := buildSourceCode(&problem)
sourceCode, err := buildSourceCode(problem)
if err != nil {
c.String(http.StatusInternalServerError, "Cannot process template %s: %v", problemId, err)
}
Expand Down
2 changes: 0 additions & 2 deletions build.sh

This file was deleted.

17 changes: 17 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ public class Solution {
assert.Equal(t, javaSourceCode, w.Body.String())
}

func BenchmarkGetSkeletonCodeForFib(b *testing.B) {
httpClient := &MockHTTPClient{problemJSON: problemsJSON}
api.SetupProblems(problemsURL, httpClient)

testRouter := setupRouter()

for i := 0; i < b.N; i++ {
resp := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/api/v1/code/java/fib", nil)
testRouter.ServeHTTP(resp, req)

if resp.Code != 200 {
b.Errorf("GET /api/v1/code/java/fib failed with response code: %d", resp.Code)
}
}
}

const problemsJSON = `[{
"id": "fib",
"func": {
Expand Down

0 comments on commit 96a47ca

Please sign in to comment.