Line Profiler



 This is my first time profiling code. I'm writing in Python and I'm having trouble using the built-in profiler, CProfiler, efficiently. CProfiler basically lists every process and how much time it takes. Although this is useful, a lot of the time consuming processes are built-in functions, and it is difficult to determine which lines in your code they are connected to.

After googling, I stumbled upon line_profiler. Line_profiler profiles a function line by line, so you know how much time each line takes. I had some trouble running the line profiler from the command line. I was able to download the source, but could not get the kernprof part of the code to display anything more than the total time the code took. Luckily, I stumbled upon this StackOverFlow post: https://stackoverflow.com/questions/23885147/how-do-i-use-line-profiler-from-robert-kern, which details how to create a line_profiler object in your code, and running it directly in your code. Since most of the google query results of line_profiler seem to be around running from the command line, it took me a while to discover that you could add it directly into your code yourself! Hopefully this revelation helps anyone else with line_profiler and command line woes. 

Comments

Popular posts from this blog

8 bit binary checksums

Converting the ASCII string value of a hex number to a hex number