Giter Club home page Giter Club logo

namegen's Introduction

๐Ÿ๏ธ

namegen's People

Contributors

anandvarma avatar gegaryfa avatar rafiramadhana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

namegen's Issues

Update README

  • Features
  • API documentation
  • Examples
  • CLI screenshots and usage

Evaluate reusing the strings.Builder object

Every call to GetForId() creates a new strings.Builder object. Although this allocation should happen on the stack and is not a concern as such, see if it would help to Reset() the builder instead of creating a new one each time. Might come in useful particularly when we need not return the string such as with #9

Implement io.Reader

See if it makes sense to implement the io.Reader interface for zero copy use-cases.

Optimize getPostfixId() memory usage

The getPostfixId implementation first encodes the random number into base-10 or base-36 and then returns a substring of it.
These encoded intermediary strings are 24 Bytes long in the common case. But the returned strings are typically 1-8 Bytes, leading to a large amount of fragmentation and trapped memory.

Extend the dictionary_test to spot duplicates across dictionaries

Today there exists logic to detect duplicates within a given dictionary of words. We need to add a test to spot duplicates across dictionaries too. For instance colors might show up in the color and adjective dictionaries which when used together could end up creating names with duplicate words in them.

Preallocate strings.Builder

Since we know the size of all the random strings as well as the postfix before hand, we can preallocate the builder to cut down on resizes and to make the memory allocations more deterministic.

Add benchmarks

Add benchmarks and optimize runtime and memory allocations.

Optimize allocations in GetForId()

GetForId() makes 3 allocations without prefix and 5 with. This is mostly down to initialized array appends and the call to strings.Join. Also evaluate and use strings.Builder to cut down on concatenation related allocations.

Benchmark outputs for reference:
BenchmarkGet-4 4428757 256.4 ns/op 65 B/op 3 allocs/op
BenchmarkGetWithPostfix-4 2684820 440.3 ns/op 162 B/op 5 allocs/op

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.