perf script: Move the number processing into its own function