Posts

Showing posts from June, 2019

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