My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions

Resources

Mastering Regular expressions by Jeffrey Fried. Chapter 6

My app on the Google play store

The app

My app’s GitHub code

The GitHub

Example

I create a for loop to warm up the JVM and allow …


This content originally appeared on DEV Community and was authored by Tristan Elliott

Resources

  • Mastering Regular expressions by Jeffrey Fried. Chapter 6

My app on the Google play store

My app's GitHub code

Example

  • I create a for loop to warm up the JVM and allow the compiler to start optimizing (This mimics a real world JVM and doing this we will get times 30% faster). start a timer, run my regular expression code 1000 times, end the timer. We do that four times and take the average. Which looks like this :
    @Test
    fun testing_again_test2(){

        val timesToDo = 1000L
        val channelName = "cohhcarnage"


        val longerParsingString = "real world example of what you want to parse"

// for loop to `warm up the JVM`
        for (i in 4 downTo 1) {
            var count = timesToDo
            val startTime = System.currentTimeMillis()
            while (--count > 0) {


  underTest.privateMessageParsing(longerParsingString,channelName) 
//privateMessageParsing() contains the matching actions we are bench marking. This is where you would substitute your own code.
            }
            val seconds = (System.currentTimeMillis() - startTime) / 1000.0
            println("Alternation takes $seconds seconds")
        }

    }

  • my next blog post will be how I was able to improve my regular expressions(this involves reading a lot of technical documentation )

Conclusion

  • Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.


This content originally appeared on DEV Community and was authored by Tristan Elliott


Print Share Comment Cite Upload Translate Updates
APA

Tristan Elliott | Sciencx (2024-09-07T23:55:11+00:00) My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions. Retrieved from https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/

MLA
" » My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions." Tristan Elliott | Sciencx - Saturday September 7, 2024, https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/
HARVARD
Tristan Elliott | Sciencx Saturday September 7, 2024 » My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions., viewed ,<https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/>
VANCOUVER
Tristan Elliott | Sciencx - » My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/
CHICAGO
" » My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions." Tristan Elliott | Sciencx - Accessed . https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/
IEEE
" » My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions." Tristan Elliott | Sciencx [Online]. Available: https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/. [Accessed: ]
rf:citation
» My notes on Android optimization. Part 2. Quick example of benchmarking Kotin regular expressions | Tristan Elliott | Sciencx | https://www.scien.cx/2024/09/07/my-notes-on-android-optimization-part-2-quick-example-of-benchmarking-kotin-regular-expressions-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.