Latest Questions tagged Performance

Browse all latest questions tagged Performance

Published 26 Apr, 2022
Python - Fastest way to get the first object from a queryset in django?

Often I find myself wanting to get the first object from a queryset in Django, or return None if there aren't any. There are lots of ways to do this which all work. But I'm wondering which is the mo...

Published 16 Apr, 2022
Javascript - What is the difference between parseInt() and Number()?

How do parseInt() and Number() behave differently when converting strings to numbers?

Published 01 Jul, 2022
Python - Why is PHP7 so much faster than Python3 in executing this simple loop?

As an extremely simple benchmark, I executed the below simple code on PHP 7.0.19-1 and Python 3.5.3 (command line) on the same Raspberry Pi 3 model B. Python's execution time was horrible in comparis...

Published 06 Sep, 2022
Java - Calling a getter in Java though reflection: What's the fastest way to repeatedly call it (performance and scalability wise)?

Given a class Foo and a property bar, neither of which I know at compile time, I need to repeatedly call the getter Foo.getBar() many, many times. Suppose I have: Method barGetterMethod = ...; // Do...

Published 15 Sep, 2022
Java - Why is creating a Thread said to be expensive?

The Java tutorials say that creating a Thread is expensive. But why exactly is it expensive? What exactly is happening when a Java Thread is created that makes its creation expensive? I'm taking the s...

Published 24 Apr, 2022
Python - Get difference between two lists

I have two lists in Python: temp1 = ['One', 'Two', 'Three', 'Four'] temp2 = ['One', 'Two'] I want to create a third list with items from the first list which aren't in the second list: temp3 = ['Thr...

Published 07 Sep, 2022
Java - Tuning GC for Java audio application

I've noticed that when playing audio in java, MarkSweepCompact stage in gc is too long and results in short periods of silence, which is unacceptable. So I need to use a low pause gc. I've tried Paral...

Published 24 Jun, 2022
Python - Get all comments from a specific reddit thread in python

The official way, r = praw.Reddit('Comment Scraper 1.0 by u/_Daimon_ see ' '' 'pages/comment_parsing.html') submission = r.get...

Published 11 Apr, 2022
Python - How to speed up python instance initialization for millions of objects?

I have defined a python class named Edge as follows: class Edge: def __init__(self): self.node1 = 0 self.node2 = 0 self.weight = 0 Now I have to create approximately 10^...

Published 27 Jun, 2022
Python - How to print iterations per second?

I have a small Python script which sends POST requests to a server and gets their response. It iterates 10000 times, and I managed to print the current progress in command prompt using: code=current...

Published 07 Jun, 2022
Reactjs - ReactJS vs AngularJS performance

I am evaluating react.js and seems like it is quite slow compared to angular.js Here is a problem with 1000 input fields with React: var Message = React.createClass({ render: function () {...

Published 26 Apr, 2022
Python - Efficient calculation of Fibonacci series

I'm working on a Project Euler problem: the one about the sum of the even Fibonacci numbers. My code: def Fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else:...

Published 13 Aug, 2022
Jquery - JQGrid Redrawing is slow

Hey Everybody! So i've had JQGrid in my application for a while now and the speed of the grid hasnt really bothered me up until I started optimization. If find that even if I have a small grid (20 i...

Published 01 May, 2022
Python - Python: count occurrences in a list using dict comprehension/generator

I want to write some tests to analyse the efficiency of different operations in python, namely a comparison of dictionary comprehensions and dict generators. To test this out, I thought I would try a...

Published 26 Apr, 2022
Python - How 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.,...