Skip to main content

Questions tagged [performance]

For questions pertaining to the measurement or improvement of code and application efficiency.

27290 votes
25 answers
1.9m views

Why is processing a sorted array faster than processing an unsorted array?

In this C++ code, sorting the data (before the timed region) makes the primary loop ~6x faster: #include <algorithm> #include <ctime> #include <iostream> int main() { // ...
GManNickG's user avatar
  • 501k
980 votes
24 answers
543k views

Big O, how do you calculate/approximate it?

Most people with a degree in CS will certainly know what Big O stands for. It helps us to measure how well an algorithm scales. But I'm curious, how do you calculate or approximate the complexity of ...
sven's user avatar
  • 18.3k
1711 votes
34 answers
874k views

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., ...
Chris Lawlor's user avatar
  • 48.3k
272 votes
9 answers
106k views

Why JSF calls getters multiple times

Let's say I specify an outputText component like this: <h:outputText value="#{ManagedBean.someProperty}"/> If I print a log message when the getter for someProperty is called and load the page,...
Sevas's user avatar
  • 4,243
640 votes
34 answers
92k views

Performance optimization strategies of last resort [closed]

There are plenty of performance questions on this site already, but it occurs to me that almost all are very problem-specific and fairly narrow. And almost all repeat the advice to avoid premature ...
1463 votes
16 answers
1.1m views

String formatting: % vs. .format vs. f-string literal

There are various string formatting methods: Python <2.6: "Hello %s" % name Python 2.6+: "Hello {}".format(name)   (uses str.format) Python 3.6+: f"{name}"   (uses f-...
NorthIsUp's user avatar
  • 17.8k
189 votes
1 answer
88k views

What is the best way to set a register to zero in x86 assembly: xor, mov or and?

All the following instructions do the same thing: set %eax to zero. Which way is optimal (requiring fewest machine cycles)? xorl %eax, %eax mov $0, %eax andl $0, %eax
balajimc55's user avatar
  • 2,265
237 votes
5 answers
63k views

When should I (not) want to use pandas apply() in my code?

I have seen many answers posted to questions on Stack Overflow involving the use of the Pandas method apply. I have also seen users commenting under them saying that "apply is slow, and should be ...
cs95's user avatar
  • 397k
4435 votes
54 answers
2.5m views

Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?

The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.? ...
314 votes
4 answers
105k views

What makes a SQL statement sargable?

By definition (at least from what I've seen) sargable means that a query is capable of having the query engine optimize the execution plan that the query uses. I've tried looking up the answers, but ...
DForck42's user avatar
  • 20.1k
1122 votes
20 answers
505k views

StringBuilder vs String concatenation in toString() in Java

Given the 2 toString() implementations below, which one is preferred: public String toString(){ return "{a:"+ a + ", b:" + b + ", c: " + c +"}"; } or public String toString(){ StringBuilder ...
non sequitor's user avatar
  • 18.6k
100 votes
3 answers
15k views

Why is the loop instruction slow? Couldn't Intel have implemented it efficiently?

LOOP (Intel ref manual entry) decrements ecx / rcx, and then jumps if non-zero. It's slow, but couldn't Intel have cheaply made it fast? dec/jnz already macro-fuses into a single uop on Sandybridge-...
Peter Cordes's user avatar
3554 votes
78 answers
1.1m views

Why is the Android emulator so slow? How can we speed up the Android emulator?

I have got a 2.67  GHz Celeron processor, and 1.21  GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android Emulator should start fairly quickly on such a machine, but ...
381 votes
13 answers
513k views

How do I obtain a Query Execution Plan in SQL Server?

In Microsoft SQL Server how can I get a query execution plan for a query / stored procedure?
Justin's user avatar
  • 86.1k
15 votes
1 answer
3k views

How to describe performance issue in relational database?

I have a query running in a relational database that doesn't fulfill the expectation of the users. What information should I provide and what should I avoid, so that I can receive an effective help ...
Marmite Bomber's user avatar

15 30 50 per page
1
2 3 4 5
841