Eng Zer Jun 0bfa5ca4d9 perf: avoid allocations with (*regexp.Regexp).MatchString (#604)
We should use `(*regexp.Regexp).MatchString` instead of
`(*regexp.Regexp).Match([]byte(...))` when matching string to avoid
unnecessary `[]byte` conversions and reduce allocations.

Example benchmark:

var allowedOrigin = regexp.MustCompile(".*.example.com")

func BenchmarkMatch(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if match := allowedOrigin.Match([]byte("www.example.com")); !match {
			b.Fail()
		}
	}
}

func BenchmarkMatchString(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if match := allowedOrigin.MatchString("wwww.example.com"); !match {
			b.Fail()
		}
	}
}

goos: linux
goarch: amd64
pkg: github.com/gotify/server/v2/api/stream
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
BenchmarkMatch-16          	 2076819	       647.7 ns/op	      16 B/op	       1 allocs/op
BenchmarkMatchString-16    	 2536326	       442.0 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/gotify/server/v2/api/stream	3.552s

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-10-23 15:57:15 +00:00
2023-09-16 21:06:54 +02:00
2021-08-04 19:39:43 +02:00
2022-11-09 19:01:20 +01:00
2023-09-16 21:06:54 +02:00
2020-05-08 15:16:43 +02:00
2020-11-01 10:47:02 +01:00
2023-09-16 21:06:54 +02:00
2023-09-17 09:05:15 +02:00
2020-02-11 17:27:22 +01:00
2023-09-16 21:06:54 +02:00
2022-05-29 19:45:45 +02:00
2018-03-02 21:04:51 +01:00
2019-03-16 14:28:09 +01:00
2019-04-04 23:03:21 +08:00
2023-09-16 21:06:54 +02:00
2023-09-17 09:05:15 +02:00
2023-09-17 09:05:15 +02:00
2019-03-08 16:03:34 +01:00
2023-09-17 09:05:15 +02:00
2021-01-06 14:27:55 +00:00
2021-09-26 20:46:58 +00:00
2019-01-20 12:00:36 +01:00

gotify/server

Build Status codecov Go Report Card Matrix Docker Pulls latest release

Intro

We wanted a simple server for sending and receiving messages (in real time per WebSocket). For this, not many open source projects existed and most of the existing ones were abandoned. Also, a requirement was that it can be self-hosted. We know there are many free and commercial push services out there.

Features

Gotify UI screenshot
  • send messages via REST-API
  • receive messages via WebSocket
  • manage users, clients and applications
  • Plugins
  • Web-UI -> ./ui
  • CLI for sending messages -> gotify/cli
  • Android-App -> gotify/android

Get it on Google Play Get it on F-Droid

(Google Play and the Google Play logo are trademarks of Google LLC.)


Documentation

InstallConfigurationREST-APISetup Dev Environment

Contributing

We welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc. Check out CONTRIBUTING.md for guidelines.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

Description
A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
Readme MIT 4.5 MiB
Languages
Go 65.9%
TypeScript 32.4%
Makefile 1.1%
HTML 0.5%