GithubHelp home page GithubHelp logo

androidregex's Introduction

AndroidRegex

Testing .NET 7 Regex on Android.

For details, see: https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/

private static readonly Regex s_myCoolRegex = new Regex("abc|def", RegexOptions.Compiled | RegexOptions.IgnoreCase);
...
if (s_myCoolRegex.IsMatch(text)) { ... }

VS the new hotness:

[RegexGenerator("abc|def", RegexOptions.IgnoreCase)]
private static partial Regex MyCoolRegex();
...
if (MyCoolRegex().IsMatch(text)) { ... }

Before (RegexOptions.Compiled)

dotnet-trace output:

RegexOptions.Compiled

IsMatch Before

Startup time on a Pixel 5 device, average of 10 runs:

Average(ms): 307.9
Std Err(ms): 2.38723456930585
Std Dev(ms): 7.54909854809757

After ([GeneratedRegex])

Note that now the static constructor of MainActivity is now so fast that it does not show up in traces at all anymore.

dotnet-trace output:

IsMatch After

Startup time on a Pixel 5 device, average of 10 runs:

Average(ms): 214.4
Std Err(ms): 3.06666666666667
Std Dev(ms): 9.69765149118303

This results in a ~93.5ms savings to startup time.

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.