Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make encoding 2x faster #3

Merged
merged 2 commits into from
Jul 23, 2017
Merged

Conversation

harukasan
Copy link
Contributor

This PR makes the LTSV encoding about 2x faster.
It includes:

  • struct reflection caching
  • using bytes.Buffer and new MarshalTo function
  • removing useless reflection
  • more tests

Benchmarks

before

go test -v -bench=. -benchtime=10s -run=none -cpuprofile=bench.cpuprofile  .
BenchmarkMarshalStruct-8   	10000000	      1935 ns/op
BenchmarkMarshalMap-8      	20000000	       816 ns/op
PASS
ok  	github.com/Songmu/go-ltsv	38.547s

CPU profile (before)

after

go test -v -bench=. -benchtime=10s -run=none -cpuprofile=bench_after.cpuprofile  .
BenchmarkMarshalStruct-8   	20000000	      1083 ns/op
BenchmarkMarshalMap-8      	50000000	       297 ns/op
PASS
ok  	github.com/Songmu/go-ltsv	37.931s

CPU profile (after)

@coveralls
Copy link

Coverage Status

Coverage increased (+15.6%) to 79.448% when pulling 0046e7d on harukasan:feature/struct_cache into be535bc on Songmu:master.

@Songmu Songmu merged commit fa2196a into Songmu:master Jul 23, 2017
@Songmu
Copy link
Owner

Songmu commented Jul 23, 2017

Great job! Thank you!

Songmu added a commit that referenced this pull request May 21, 2022
## [v0.1.0](69c2279...v0.1.0) (2022-05-22)

* introduce Go Modules and GitHub Actions [#6](#6) ([Songmu](https://github.com/Songmu))
* Support encoding/decoding bool value [#5](#5) ([hottestseason](https://github.com/hottestseason))
* Reduce allocations by avoiding strings.Split [#4](#4) ([itchyny](https://github.com/itchyny))
* Make encoding 2x faster [#3](#3) ([harukasan](https://github.com/harukasan))
* introduce teble driven tests [#2](#2) ([Songmu](https://github.com/Songmu))
* care Null number [#1](#1) ([Songmu](https://github.com/Songmu))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants