Recent Entries 10
- snippet critical 112d agoHow do I profile C++ code running on Linux?How do I find areas of my code that run slowly in a C++ application running on Linux?
- snippet critical 112d agoHow to measure time taken by a function to executeI need to get execution time in milliseconds. Note: I originally asked this question back in 2008. The accepted answer then was to use `new Date().getTime()` However, we can all agree now that using the standard `performance.now()` API is more appropriate. I am therefore changing the accepted answer to this one.
- pattern critical 112d agoWhich Python memory profiler is recommended?I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are PySizer and Heapy. I haven't tried anyone, so I wanted to know which one is the best considering: - Gives most details. - I have to do least or no changes to my code.
- gotcha critical 112d agoWhy does Python code run faster in a function?``` def main(): for i in xrange(10**8): pass main() ``` This piece of code in Python runs in (Note: The timing is done with the time function in BASH in Linux.) ``` real 0m1.841s user 0m1.828s sys 0m0.012s ``` However, if the for loop isn't placed within a function, ``` for i in xrange(10**8): pass ``` then it runs for a much longer time: ``` real 0m4.543s user 0m4.524s sys 0m0.012s ``` Why is this?
- snippet critical 112d agoHow do I profile a Python script?Project Euler and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometimes the approaches are somewhat kludgey - i.e., adding timing code to `__main__`. What is a good way to profile how long a Python program takes to run?
- pattern critical 112d agoWhich Python memory profiler is recommended?I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is Python Memory Validator (Windows only). And open source ones are PySizer and Heapy. I haven't tried anyone, so I wanted to know which one is the best considering: - Gives most details. - I have to do least or no changes to my code.
- gotcha critical 112d agoWhy does Python code run faster in a function?``` def main(): for i in xrange(10**8): pass main() ``` This piece of code in Python runs in (Note: The timing is done with the time function in BASH in Linux.) ``` real 0m1.841s user 0m1.828s sys 0m0.012s ``` However, if the for loop isn't placed within a function, ``` for i in xrange(10**8): pass ``` then it runs for a much longer time: ``` real 0m4.543s user 0m4.524s sys 0m0.012s ``` Why is this?
- snippet critical 112d agoHow do I profile a Python script?Project Euler and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometimes the approaches are somewhat kludgey - i.e., adding timing code to `__main__`. What is a good way to profile how long a Python program takes to run?
- debug major pending 121d agoDebug: Python memory usage growing unexpectedlyPython application memory usage keeps growing over time, indicating a memory leak.
- debug moderate pending 121d agoDebug: React app slow rendering and performance profilingReact application feels slow, components re-render too often, or interactions are laggy.