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

Benchmark ULString #44

Closed
1 task done
SupinePandora43 opened this issue Dec 27, 2021 · 0 comments
Closed
1 task done

Benchmark ULString #44

SupinePandora43 opened this issue Dec 27, 2021 · 0 comments

Comments

@SupinePandora43
Copy link
Owner

SupinePandora43 commented Dec 27, 2021

Benchmarks

  • Marshal.AllocHGlobal and Encoding.GetBytes
  • Cashed Marshal.AllocHGlobal and Encoding.GetBytes
  • Marshal.StrToCoTaskMem
  • stackalloc and Encoding.GetBytes
  • Ultralight.ulCreateString

Results

  • :P
  • Faster than run-time heap allocation
  • No
  • Same as Cached memory
  • Slow on short lengths (0-1) fast in all other cases.

Verdict

  • Use ulCreateString16 for managed->native calls
  • don't use if/else size checks because they will probably lower performance (correct me in future)

Pros

  • blazingly fast

Cons

  • slower on nano lengths (0-16~ bytes)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant