premature-optimization Questions

11

Solved

I have heard a teacher drop this once, and it has been bugging me ever since. Let's say we want to check if the integer x is bigger than or equal to 0. There are two ways to check this: if (x >...

13

say suppose I have class as : public class Age { private int age; public int getAge() { return this.age; } } In my Main class I am calling the getAge() method many times. So I wanted to ...
Tangerine asked 12/5, 2010 at 17:16

6

Solved

There are two types of if statements in java - classic: if {} else {} and shorthand: exp ? value1 : value2. Is one faster than the other or are they the same? statement: int x; if (expression) { ...

1

Solved

There are some articles available online where they mention some of the cons of using Stream-s over old loop-s: https://blog.jooq.org/2015/12/08/3-reasons-why-you-shouldnt-replace-your-for-loops-...

3

Solved

I need to iterate over lots of (2D) data and only sometimes handle special cases. For my application speed is the most critical factor. The options that quickly come to (my) mind are: Option A: ...
Bravura asked 13/7, 2019 at 10:17

11

Is there any performance benefit one way or another? Is it compiler/VM specific? I am using Hotspot.
Deuterogamy asked 27/9, 2010 at 15:10

20

Solved

As Knuth said, We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. This is something which often comes up in Stack Overf...
Trombone asked 22/12, 2008 at 3:50

3

Solved

I've been struggling with an application I'm writing and I think I'm beginning to see that my problem is premature optimization. The perfectionist side of me wants to make everything optimal and pe...
Nurmi asked 9/6, 2010 at 1:49

11

Solved

In java I usually make a for-loop like following: for (int i = 0; i < max; i++) { something } But recently a colleague typed it so: for (int i = 0; i < max; ++i) { something } He said...
Michaels asked 28/1, 2011 at 18:29

3

Solved

This might be a silly question to ask, but this kind of optimization is sometimes boost performance of your application. Here I am asking specifically for C++, because the way C++ compile cod...
Portrait asked 22/5, 2015 at 10:57

9

Solved

We should develop on slow boxen because it forces us to optimize early. Randall Hyde points out in The Fallacy of Premature Optimization, there are plenty of misconceptions around the Hoare quo...
Brathwaite asked 21/10, 2009 at 16:32

6

Solved

I'm looking over a document that describes various techniques to improve performance of Lua script code, and I'm shocked that such tricks would be required. (Although I'm quoting Lua, I've seen sim...
Farny asked 10/1, 2011 at 5:1

5

Solved

In a framework such as Django, I'd imagine that if a user lands on a page (running a view function called "some_page"), and you have 8 imports at the top of module that are irrelevant to that view,...

5

Solved

I've learned that Xor operation can be used to implement effective swap function. like this: template<class T> void swap(T& a, T& b) { a = a^b; b = a^b; a = a^b; } But the imple...

3

Solved

Please consider the following jQuery code: if ($(this).is(':hidden')) { $(this).show(); } My Question: Is it worthwhile to check for the element's visibility before issuing the show() command...

1

Solved

If I take a slice of a table using, say the column names, does R allocate memory to hold the slice in a new location? Specifically, I have a table with columns depth1 and depth2, among others. I wa...
Impertinence asked 16/3, 2011 at 22:38

5

Solved

I'd like to 'shear' a numpy array. I'm not sure I'm using the term 'shear' correctly; by shear, I mean something like: Shift the first column by 0 places Shift the second column by 1 place Shift t...
Paolo asked 14/2, 2011 at 23:36

6

Solved

I've had no real luck getting a concise answer for this comparison by using Google and rather than do my own time consuming evaluations, I thought I would ask first. I'm fairly sure that a switch ...
Canoewood asked 7/2, 2011 at 15:17

10

I see this term used a lot but I feel like most people use it out of laziness or ignorance. For instance, I was reading this article: http://blogs.msdn.com/b/ricom/archive/2006/09/07/745085....
Disquietude asked 28/1, 2011 at 20:16

2

Solved

Which of these is more efficient in ColdFusion? isDefined('url.myvar') or structKeyExists(url, 'myvar')

8

Solved

Is the difference between integer multiply(temporarily forgetting about division) still in favor of shifting and if so how big is the difference? It simply seems such a low level optimization, eve...
Prismatic asked 1/10, 2010 at 4:56

5

Solved

I recently saw a piece of code at comp.lang.c++ moderated returning a reference of a static integer from a function. The code was something like this int& f() { static int x; x++; return x;...
Chalmer asked 9/8, 2010 at 13:59

19

Solved

The question seems settled, beaten to death even. Smart people have said smart things on the subject. To be a really good programmer, you need to know C. Or do you? I was enlightened twice this w...
Gregoriogregorius asked 21/5, 2010 at 13:44

7

Solved

I have a page where I have 4 tabs displaying 4 different reports based off different tables. I obtain the row count of each table using a select count(*) from <table> query and display numb...
Pedanticism asked 27/4, 2010 at 10:11

6

Solved

I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet()) { System.out.println(key); System.out.println(myMap.get(key)); } So is myMap.keySet() call...
Mehalek asked 24/5, 2009 at 20:30

© 2022 - 2024 — McMap. All rights reserved.