Fasthttp: Thanks fasthttp for performance & zero memory allocations.

Created on 10 Jan 2020  路  3Comments  路  Source: valyala/fasthttp

Hi,

I develop an interface for the Neo4j HTTP API.
fasthttp is very powerful.

Thanks

Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ POC\Neo4j\test -bench ^(Benchmark_Neo4j_HTTP_API)$ -v

goos: windows
goarch: amd64
pkg: POC/Neo4j/test
Benchmark_Neo4j_HTTP_API-4 1000000000 0.00105 ns/op 0 B/op 0 allocs/op
PASS
ok POC/Neo4j/test 0.537s
Success: Benchmarks passed.

All 3 comments

0.00105 ns/op is only possible if your benchmark isn't doing anything. Are you sure you are benchmarking correctly?

Mm-hmm... Thanks for the advice.
I'm looking at.

you're right. Here are more consistent results
=> 0.0015897 Seconds per fasthttp request.
it remains for me to identify the reason for the memory consumption (4399 B/op & 68 allocs/op)

Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ POC\Neo4j\test -bench ^(Benchmark_Neo4j_HTTP_API)$ -v

goos: windows
goarch: amd64
pkg: POC/Neo4j/test
Benchmark_Neo4j_HTTP_API-4 685 1589700 ns/op 4399 B/op 68 allocs/op
PASS
ok POC/Neo4j/test 2.555s
Success: Benchmarks passed.

func Benchmark_Neo4j_HTTP_API(b *testing.B) {
    var (
        neo4jClient    *neo4jhttpclient.Neo4jHTTPClient
        neo4jResults   *neo4jhttpclient.ResponseData
        neo4jStatement string
        err            error
    )

    neo4jClient, err = neo4jhttpclient.New("localhost", "7474", "neo4jUser", "neo4jPasswd")
    assert.Nil(b, err)

    neo4jStatement = `RETURN 1`

    for n := 0; n < b.N; n++ {
        neo4jResults, err = neo4jClient.PostByte("transaction/commit", neo4jStatement)
        assert.Nil(b, err)
        assert.Equal(b, 0, len(neo4jResults.Errors))
        assert.Equal(b, 1, len(neo4jResults.Results))
        assert.Equal(b, 1, len(neo4jResults.Results[0].Columns))
        assert.Equal(b, 1, len(neo4jResults.Results[0].Data))
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jadbox picture jadbox  路  3Comments

gogoods picture gogoods  路  3Comments

Fenny picture Fenny  路  3Comments

danilobuiatti picture danilobuiatti  路  3Comments

ohenepee picture ohenepee  路  4Comments