"Written correctly"
All performance related issues are accounted for.
Extensive use of "in-placeness".
Use best performing native functions etc.
Many of these questions are covered in the LV advanced course.
If you are going to do the check in software, write a benchmark routine that tests just how long it takes to do what you are trying. Once you get the rigth code assembled, then integrate into your app.
Keep asking, we'll keep answering.
Ben