Latest Questions tagged Performance

Browse all latest questions tagged Performance

263
Votes
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...

56
Votes
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...

391
Votes
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?

47
Votes
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...

665
Votes
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...

118
Votes
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...

42
Votes
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 ' 'https://praw.readthedocs.org/en/latest/' 'pages/comment_parsing.html') submission = r.get...

6
Votes
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^...

30
Votes
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...

29
Votes
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:...

105
Votes
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...

25
Votes
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 () {...

51
Votes
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...

62
Votes
Published 01 Sep, 2022
Java - Optional vs if/else-if performance java 8

Hello i have two samples of code if/else if/else statements private Object getObj(message) { if (message.getA() != null) return message.getA(); else if (message.getB() !=...

97
Votes
Published 26 Jul, 2022
Python - Performance of various numpy fancy indexing methods, also with numba

Since for my program fast indexing of Numpy arrays is quite necessary and fancy indexing doesn't have a good reputation considering performance, I decided to make a few tests. Especially since Numba i...