Software engineering and personal development

Tag: performance

How to Calculate the Time Spent in Python

In programming, it’s important to optimize code for performance. One way to do this is by measuring how long it takes for code to execute. In this blog post, we will explore a Python snippet that can be used to calculate the time it takes to execute a particular piece of code.

Python’s time module provides a simple way to measure the execution time of a program. The time.time() function returns the current time in seconds since the epoch (January 1, 1970, 00:00:00 UTC) as a floating-point number. We can use this function to measure the time before and after a particular piece of code and calculate the difference to get the total time it took to execute the code.

Continue reading

A very efficient way to do string concatenations in Ruby

Img source: medium.com

It is very difficult to think about an application that does not have any string data type. Names, emails, object attributes, etc. are very common. Knowing their wide usages, it is obvious that we should at least learn the best practices about them. I recently learned about the difference between the efficiency of two similar string functions, which was a bit surprising and that made me write this article. Although both methods do the concatenation of strings, there is a big difference in their performance.

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑