Giter Site home page Giter Site logo

elliotwutingfeng / asciiset Goto Github PK

View Code? Open in Web Editor NEW
6.0 0.0 0.0 110 KB

asciiset is an ASCII character bitset.

License: BSD 3-Clause "New" or "Revised" License

Makefile 3.14% Go 96.86%
ascii bitmask bitset bitwise byte data-structures string set hacktoberfest

asciiset's Introduction

asciiset

Go Reference Go Report Card Coveralls

GitHub license

Summary

asciiset is an ASCII character bitset.

Bitsets are fast and memory-efficient data structures for storing and retrieving information using bitwise operations.

asciiset is an extension of the asciiSet data structure from the Go Standard library source code.

Possible applications include checking strings for prohibited ASCII characters, and counting unique ASCII characters in a string.

Spot any bugs? Report them here.

ASCII Table

Installation

go get github.com/elliotwutingfeng/asciiset

Testing

make tests

# Alternatively, run tests without race detection
# Useful for systems that do not support the -race flag like windows/386
# See https://tip.golang.org/src/cmd/dist/test.go
make tests_without_race

Benchmarks

make bench

Results

CPU: AMD Ryzen 7 5800X
Time in nanoseconds (ns) | Lower is better

ASCIISet

     Add() โ–  891 ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ 11x faster

Contains() โ–  580 ๐ŸŸฆ๐ŸŸฆ 28x faster

  Remove() โ– 1570 ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ 1.5x faster

    Size() โ–  313 ๐ŸŸฆ equivalent

   Visit() โ– 1421 ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ๐ŸŸฆ 3.5x faster

map[byte]struct{}

     Add() โ– 9850 ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ

Contains() โ–16605 ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ

  Remove() โ– 2510 ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ

    Size() โ–  318 ๐ŸŸฅ

   Visit() โ– 5085 ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ๐ŸŸฅ
go test -bench . -benchmem -cpu 1
goos: linux
goarch: amd64
pkg: github.com/elliotwutingfeng/asciiset
cpu: AMD Ryzen 7 5800X 8-Core Processor
BenchmarkASCIISet/ASCIISet_Add()                 1340958               891.8 ns/op             0 B/op          0 allocs/op
BenchmarkASCIISet/ASCIISet_Contains()            2058140               580.9 ns/op             0 B/op          0 allocs/op
BenchmarkASCIISet/ASCIISet_Remove()               762636              1570 ns/op               0 B/op          0 allocs/op
BenchmarkASCIISet/ASCIISet_Size()                3808866               313.2 ns/op             0 B/op          0 allocs/op
BenchmarkASCIISet/ASCIISet_Visit()                840808              1421 ns/op               0 B/op          0 allocs/op
BenchmarkMapSet/map_Add                           122043              9850 ns/op               0 B/op          0 allocs/op
BenchmarkMapSet/map_Contains                       72583             16605 ns/op               0 B/op          0 allocs/op
BenchmarkMapSet/map_Remove                        451785              2510 ns/op               0 B/op          0 allocs/op
BenchmarkMapSet/map_Size                         3789381               318.3 ns/op             0 B/op          0 allocs/op
BenchmarkMapSet/map_Visit                         235515              5085 ns/op               0 B/op          0 allocs/op
PASS
ok      github.com/elliotwutingfeng/asciiset    14.438s

asciiset's People

Contributors

elliotwutingfeng avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

asciiset's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-go v5
  • actions/setup-go v5
  • coverallsapp/github-action v2
  • actions/checkout v4
gomod
go.mod

  • Check this box to trigger a request for Renovate to run again on this repository

Clarify licensing

According to CREDITS.md, some code is sourced from a project licensed under BSD-2-Clause, but does not specify which. Could you please clarify which file(s) contain this code, and whether they are multilicensed under both BSD-3-Clause and BSD-2-Clause?

Thanks,
Maytham

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.