Skip to content

hiago-balbino/hgz-protobuffer-comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

continuous-integration continuous-integration

Comparison between Protocol Buffer & JSON

Sample project to compare Protocol Buffer versus JSON.


Configure environment variable

To run the project you need to install the GNU Make, protobuffer compiler and go code generator.

  • Protobuffer compiler
  • Go code generator
    • go install google.golang.org/protobuf/cmd/protoc-gen-go
  • GNU Make
    • The way to install will depend on your system environment
  • Docker
  • Docker Compose
  • Redis Client
    • You can install any Redis Client for your system to login and show all saved values

Commands

  • make help

    • Show all make commands
  • make compile-protoc-win

    • For that, you need to have $PROTOC name as an environment variable to protoc
    • Generates go code from proto file to Windows
  • make compile-protoc-macos

    • Generates go code from proto file to MacOS
  • make run-proto

    • Run Protocol Buffer project and insert data on cache
  • make run-json

    • Run JSON project and insert data on cache
  • make docker-build-up

    • Build and start all containers
  • make docker-up

    • Start all containers
  • make docker-down

    • Stop all containers
  • make docker-ps

    • Show all containers running
  • make proto-bench

    • Run all benchmark tests to protocol buffer format
  • make json-bench

    • Run all benchmark tests to json format

Results

Presenting the results of running benchmark tests to compare Marshal and Unmarshal using Protocol Buffer and JSON, as well as Redis memory usage with 10,000 inserted items

Tips:

  • Each test ran for 10 seconds
  • The first column is the number of iterations run, this is a fairly light process, so it completes quickly, and many iterations can be run
  • ns/op column - this is the average time each function call takes to complete
JSON

json-bench-result

# Redis
used_memory: 2965888
PROTOCOL BUFFER

Marshal: ≅26% more performative

Unmarshal: ≅85% more performative

proto-bench-result

# Redis (≅25% less memory used)
used_memory: 2225616

About

Sample project to compare Protobuffer versus JSON.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published