Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: string.starts_with and string.ends_with by 10x in TCC #22620

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

enghitalo
Copy link
Contributor

@enghitalo enghitalo commented Oct 22, 2024

10x faster in TCC
image

import benchmark

const max_iterations = 1_000_000

fn main() {
	value := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
	mut b := benchmark.start()
	for i := 0; i < max_iterations; i++ {
		value.starts_with('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')
		// value.ends_with('pqrstuvwxyzabcdefghijklmnopqrstuvwxyz')
	}
	b.measure("value.starts_with('abcd')")
}

Huly®: V_0.6-21069

@enghitalo enghitalo changed the title perf: string.starts_with perf: string.starts_with and string.ends_with by 10x in TCC Oct 22, 2024
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit b5795dc into vlang:master Oct 22, 2024
78 checks passed
@felipensp
Copy link
Member

Nice catch. 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants