Most voted "performance" questions
For questions involving measurement and improvement of code efficiency
Learn more…479 questions
Sort by count of
-
13
votes3
answers2628
viewsHow to optimize this function for Fibonacci sequence?
On the website codility there is an initial challenge for you to refactor this code: var yourself = { fibonacci : function(n) { if (n === 0) { return 0; } if (n === 1) { return 1; } else { return…
-
13
votes1
answer354
viewsPerformance Webpack Build.js
I’m starting with Webpack. It compiles all javascript and css files into a single file Build.js, Bundle.js, whatever it is... In the end it generates a fully minified file using the Node command…
-
13
votes1
answer286
viewsWhat are Zero Cost Abstractions?
I was reading about Rust and I saw that one of its advantages is to own Zero Cost Abstractions, I would like to know: What are Zero Cost Abstractions? It is something that the programmer needs to…
-
12
votes2
answers437
viewsPerformance difference of Any() and Count()
When I need to check whether a Collection has or has not elements which of the two methods will be faster, .Count() =! 0 or .Any()? I’ve heard that the .Count() may be faster in some cases. But by…
-
12
votes1
answer1018
viewsMinify HTML code
It is normal to see minified Javascript files, for performance gain. Today we see some sites that minify everything, including the code itself HTML, as an example east of here. (use the option to…
-
12
votes4
answers750
viewsHow to limit the resources used by the system?
I have a loop loop that makes several iterations and has in its scope calculations that require a lot of processing. The problem is that when executing the code snippet, the use of the processor…
-
12
votes3
answers307
viewsIs there a difference in performance between "echo" content and HTML content?
The use of echo PHP to display on the screen any content differs in performance to use this same content directly in HTML? For example, if I use a PHP file: <?php echo "<p>Seja bem-vindo ao…
-
12
votes4
answers229
viewsIs overloading methods less performatic?
I was reading about interfaces as part of my studies and came across an overloaded class (overloading) methods, with two comments saying that it should be avoided. I was in doubt about it affecting…
-
12
votes2
answers188
viewsIs there a difference in performance between "new" and "clone" in PHP?
What is the advantage of using the clone instead of the new to create an object in PHP? I know that to use the clone it is necessary to pass an instantiated object. But because it is not necessary…
-
11
votes2
answers536
viewsWhy invert the array index in a for, to popular the array, makes the process faster?
I was doing some tests in Java and I noticed a very strange behavior. I made an array with two dimensions and populated the array in two different ways, filling with random numbers up to 2 31-1 and…
-
11
votes4
answers584
viewsHow to verify the efficiency of these 2 functions in C++?
How to determine the best choice between these two functions for implementation? 1: int X(int x){ if(x<=0) return 0; return(x + X(x-1)); } 2: int Y(int x){ int soma=0; for(int i=0;i<=x;++i)…
-
11
votes1
answer255
viewsCanonicalized Mapping and Weakreference
I would like someone to explain the concept (and applications) of Canonicalizing Mapping and how your reference implementation would work using Weakhashmap.…
java performance memory-management hashmap garbage-collectorasked 9 years, 7 months ago Reginaldo Soares 2,256 -
11
votes1
answer27744
viewsConcatenate Strings into Java Loops - Stringbuilder or '+'?
Java allows us to concatenate Strings in Java using only the operator '+' String str = "a" + "b" + "c"; It’s a simple way to do the job, and much less verbose than with Stringbuilder. But in cases…
-
11
votes4
answers2951
viewsWhat ways to measure the performance of an algorithm?
If I have, for example, some sorting algorithms (Merge Sort, Quick Sort, Bubble Sort...) in which way(s) I can know the efficiency of each one?
-
11
votes2
answers121
viewsIs there an alternative to Removeat()?
I am using Entity Framework in an ASP.NET MVC project where I have a simple list of strings and need to remove only the first item. I used the following command: minhaLista.RemoveAt(0); Well, but…
-
11
votes1
answer323
viewsWhat are build cache structures?
In that question where I wanted to know if I should store settings in a global variable $GLOBALS, I got some very good answers, and there was one that talked about something that I hadn’t even…
-
11
votes2
answers1385
viewsWhen to use "inline"?
Everybody says you don’t have to use inline functions since the compiler knows what to do better than the programmer. But if it has in the language it should serve for something. Is it useful in any…
-
11
votes2
answers5134
viewsWhat makes Join() so superior compared to other concatenation techniques?
It is common to read that the method of concatenation join() is a lot superior what other techniques in Python (such as + or +=). Starting from this point, I ask some questions: What does the join()…
-
11
votes2
answers283
viewsWhat is the difference between using a comparison with >= or simply >?
Imagine the following scenario. int i = 2; if(i >= 2) { //.... } When we could just summarize to; int i = 2; if(i > 1) { //.... } My doubts with these two expressions are as follows:: When a…
-
11
votes1
answer961
viewsWhat makes Kotlin a language faster than Java?
I have read in some articles that Kotlin is faster than Java, but none of them exemplifies why. [...] As fast as Java". Kotlin - Evolve your Java Code (TDC-2016) Alex Magalhaes [...] Kotlin should…
-
11
votes4
answers455
viewsWhat is the difference between parseint() and operator + before a string?
I saw a colleague convert a string to integer using the syntax var a = +"10" but I always used the parseInt() and the line is usually like this var a = parseInt("10"). Why when placing the operator…
javascript string performance operators type-conversionasked 6 years, 4 months ago Hiago Souza 5,837 -
11
votes1
answer293
viewsWhat is and how does CSS Post-processing work?
What would be a CSS post-processing? I’ve heard of pre-processed CSS, like Gulp does when it compiles a SASS in CSS. But recently I heard the term post-processed CSS and I didn’t really understand…
-
10
votes3
answers9148
viewsQuery in two tables without INNER JOIN
I would like to know, is there a difference in the performance of these two queries? in Mysql SELECT employee.*, company.name FROM company, employee WHERE employee.company_id = company.id AND…
-
10
votes2
answers16045
viewsForeach or lambda in lists
Which one do I get the best performance to get the value of a given in a list? I do foreach or lambda(when possible, of course)? I can have this: foreach(var i in lista) { var teste = i.NmCampo; }…
-
10
votes3
answers2257
viewsWhich loop is faster in C: while or for?
Being a bond while and a for that run the same number of times, which is faster? Example: while: int i = 0; int max = 10; while(i<max){ funcao(); i++; } for: int i; int max = 10; for(i=0;…
-
10
votes5
answers26385
viewsWhat is the best practice to know if an Row exists in a SELECT in Mysql?
For example, when we check if a user is already registered in the table, we do not need any data return by query, just check if the number of Rows is greater than 0 (num_rows > 0). Us scripts and…
-
10
votes3
answers2010
viewsHow to optimize the sum of elements in an array
I need to get the sum of the items of a array javascript. The quantity of these items can easily reach 2,000 items. The items are of the type int, no need to test. ar = [1,3,5,...,2000]; I already…
-
10
votes3
answers302
viewsWhat is the cost of calling many functions?
Recently, faced with a discussion about Clean Code and programming best practices, a co-worker commented that in his previous job he had a lot of resistance on the part of the other programmers to…
-
10
votes1
answer471
viewsHow can you check if the number is in between so fast?
It is known that with the module timeit it is possible to measure, in Python, the execution time of code snippets. Curious, I was testing what is the time it takes to verify if a certain number is…
-
10
votes1
answer328
viewsHow to analyze the performance impact of a code snippet in ADVPL?
I have the following code in ADVPL: Static Function linhaJson(cTabela, cChave, lVerificaExclusao) local cTipo local xResult local cJson := "{" dbSelectArea("ZX1") ZX1->(dbSetOrder(1))…
-
9
votes1
answer5967
viewsWhat’s the difference between drawing in Activity and in Fragment?
After the last SDK update in Eclipse, when creating a new project, a fragment next to activity_main. I would like to know why the fragment, since before it opened directly to activity_main. Is there…
-
9
votes2
answers660
viewsCDN vs. join JS/CSS
Among the performance recommendations of a web system are: Use CDN (in case of jQuery, Bootstrap, etc) Join JS and CSS to decrease the number of requests Turns out those two rules go against each…
-
9
votes1
answer2214
viewsJavascript performance: switch or if nested?
Which of the two alternatives provides the best performance in Javascript: nested switch or if? if { ... } else { if { ... } else { if { ... } else { ... } } } or switch(expression) { case n: code…
-
9
votes3
answers739
viewsCan a video accelerator card improve non-fiction performance?
To develop in Ruby on Rails, I use here a virtual machine of Virtualbox with Ubuntu Server 14.04 without graphical interface installed. I recently discovered a configuration that dramatically…
performanceasked 10 years, 4 months ago user7261 -
9
votes3
answers10114
viewsWhich JSON structure to use for large data volume without loss of performance?
I am thinking about using JSON in a project, because it is highly accepted and there are many libraries ready that encode and decode it in other objects (arrays, for example), but there is something…
-
9
votes1
answer87
viewsRamdrive with video card ram
I use the R language for heavy matrix calculations. I’m using gpu for performance gain, which is fantastic indeed. However, I would like to take another step and dump the 2gb data matrix directly…
-
9
votes2
answers1839
viewsWhich one performs better? For or Foreach+Range?
Of the two forms below, which has a better performance? For: for( $x=1; $x < 31; $x++ ) echo $x . PHP_EOL; Foreach + range: foreach( range(1,30) as $x ) echo $x . PHP_EOL; I know the difference…
-
9
votes1
answer1095
viewsBiometric readers output standard on fingerprint
I would like to know the following questions from someone who has worked with a biometric fingerprint reader: The outputs of biometric readers are standard, ie a reader model A of an X mark follows…
-
9
votes2
answers521
viewsPerformance difference between multiple conditions in one IF or multiple IF’s separately?
During a change in a source code, I came across the following situation, developed by another developer: if ( booleano1 || booleano2 || booleano3 ) { if( booleano1 ) { //faz algo } if( booleano2 ) {…
-
9
votes5
answers1956
viewsDifference between JSON and String data
I’m just finishing building a website on PHP with architecture MVC, the next step is to integrate the application (I only have the interface) with the core(controller) site, to fetch information…
-
9
votes1
answer256
viewsWhat is an unrolling?
In this question I asked about optimization and performance that the compiler performs. Among the highlighted items, users commented that the compiler makes an optimization called loop unwinding or…
-
9
votes4
answers2583
viewsCan PHP’s unset() function improve performance?
I think the answer to my question would be "yes." even because I end up doing it in my code (when I remember), but I just stopped to think about it now and I’m kind of worried if someone asked me…
-
9
votes1
answer126
viewsA property occupies space in the object?
I was reading a question about properties and saw that she is at the same time one or two methods. Do you have any additional cost in memory and processing in using it? If you don’t use the code you…
-
9
votes2
answers750
viewsHow to improve the performance of my code with "for"?
I have the following code: for ($i=0; $i < 10; $i++) { for ($j=0; $j < 20; $j++) { for ($p=0; $p < 40; $p++) { echo $vaar[$i][$j][$p]; } } } I believe a code that contains a for inside…
-
9
votes1
answer158
viewsHow to compare relative run time of fast algorithms?
The @Sorack asked the following questions about performance: What’s the most performative way to convert an int into the sum of its digits? What’s the most performative way to convert int[] to int?…
-
9
votes2
answers1801
viewsAsync/Await with threads (C# 7.2)
I have this code and as you can see I created two examples, Parallel and Notparallel. I expected both to return me 3000ms, because both should run async (2000 and 3000) and the total time would be…
-
8
votes3
answers920
viewsCan using non-priminal variable type in C# affect performance?
Using non-priminal variable type in C# can affect performance? I have seen several codes where, instead of using primitive C#types, many use types similar to other languages that the IDE accepts. I…
-
8
votes3
answers4774
viewsHow to improve file recording speed for a Clientdataset?
I’m integrating a system with a bank file, and I’m having a problem with the process. I receive from the credit card operator a plain text file with approximately 1300Kb and about 5,500 lines. I’m…
-
8
votes2
answers209
viewsProcessing time is affected by the size of variable names?
I was analyzing some frameworks developed by large companies and noticed a certain uniqueness, its variables and functions usually have small names. Variable or function name size interferes with…
performance variables encoding-style response-timeasked 10 years, 2 months ago Guilherme Lautert 15,097 -
8
votes3
answers1971
viewsRecords with recurring dates filtered for a period
The Problem I am creating a financial system where I need to register a recurring movement, for example, a light bill that repeats every month. In the system, this type of movement is treated as a…