Giter Site home page Giter Site logo

learn-go-reflect's Introduction

benchmark

todo

  • benchmark for protobf

介绍

benchmark将对象的创建也放到了基准测试中,benchmark2没有

benchmark

| Func                              |    ops/s |    ns/op    |
| --------------------------------- | -------: | :---------: |
| Benchmark_Direct_Set-16           | 45673189 | 25.48 ns/op |
| Benchmark_Reflect_Set-16          | 27042921 | 40.57 ns/op |
| Benchmark_Reflect_FiledByIndex-16 | 20692100 | 52.14 ns/op |
| Benchmark_Reflect_FiledByName-16  |  6617115 | 190.1 ns/op |

benchmark2

| Func                              |      ops/s |    ns/op     |
| --------------------------------- | ---------: | :----------: |
| Benchmark_Direct_Set-16           | 1000000000 | 0.2491 ns/op |
| Benchmark_Reflect_Set-16          |  838860561 | 1.415 ns/op  |
| Benchmark_Reflect_FiledByIndex-16 |   50546955 | 23.33 ns/op  |
| Benchmark_Reflect_FiledByName-16  |    4385136 | 264.9 ns/op  |

struct/interface call method

| Func                                |      ops/s |    ns/op     |
| ----------------------------------- | ---------: | :----------: |
| Benchmark_StructPointerMetodCall-16 | 1000000000 | 0.2387 ns/op |
| Benchmark_StructInterfaceCall-16    | 1000000000 | 1.208 ns/op  |

| Func                    | ops/s |      ns/op      |
| ----------------------- | ----: | :-------------: |
| Benchmark_SortIface-16  |     6 | 166848069 ns/op |
| Benchmark_SortStruct-16 |    19 | 59353636 ns/op  |

cmd:

go test -bench=. -benchmem or go test -bench=regex -benchmem

ref:

https://github.com/KippaZou/learn-reflection

learn-go-reflect's People

Watchers

James Cloos avatar Rick_Xu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.