tagged [optimization]

C#/XNA - Multiplication faster than Division?

C#/XNA - Multiplication faster than Division? I saw a tweet recently that confused me (this was posted by an XNA coder, in the context of writing an XNA game): [Microoptimization tip of the day: when ...

How to identify unused CSS definitions from multiple CSS files in a project

How to identify unused CSS definitions from multiple CSS files in a project A bunch of CSS files were pulled in and now I'm trying to clean things up a bit. How can I efficiently identify unused CSS d...

Fastest way to convert string to integer in PHP

Fastest way to convert string to integer in PHP Using PHP, what's the fastest way to convert a string like this: `"123"` to an integer? Why is that particular method the fastest? What happens if it ge...

27 Oct at 05:21

What is the real overhead of try/catch in C#?

What is the real overhead of try/catch in C#? So, I know that try/catch does add some overhead and therefore isn't a good way of controlling process flow, but where does this overhead come from and wh...

constrained nonlinear optimization in Microsoft Solver foundation vs Matlab fmincon

constrained nonlinear optimization in Microsoft Solver foundation vs Matlab fmincon can anyone show me examples or reviews for constrained nonlinear optimization in Microsoft Solver foundation 3.0? Ho...

Should I use one big SQL Select statement or several small ones?

Should I use one big SQL Select statement or several small ones? I'm building a PHP page with data sent from MySQL. Is it better to have - `SELECT`- `SELECT` Which is faster and what is the pro/con of...

1 Feb at 16:38

Faster modulus in C/C#?

Faster modulus in C/C#? Is there a trick for creating a faster integer modulus than the standard % operator for particular bases? For my program, I'd be looking for around 1000-4000 (e.g. n%2048). Is ...

17 Aug at 04:53

Does the C# compiler remove an if that encapsulates a debug.writeline

Does the C# compiler remove an if that encapsulates a debug.writeline I have a piece of code like this: Does the compiler optimize this away if i make a release build? Or does the evaluation stay and ...

14 Dec at 12:52

Is it worth from a browser's performance perspective to compress http responses?

Is it worth from a browser's performance perspective to compress http responses? The browser is probably closer to be CPU-constraint than network constraint, right? We have a very heavy ajax applicati...

26 Feb at 09:20

Fastest way to iterate over a stack in c#

Fastest way to iterate over a stack in c# I feel that using GetEnumerator() and casting IEnumerator.Current is expensive. Any better suggestions? I'm open to using a different data structure if it off...

12 Nov at 03:24

Does setting the platform when compiling a c# application make any difference?

Does setting the platform when compiling a c# application make any difference? In VS2012 (and previous versions...), you can specify the target platform when building a project. My understanding, thou...

What's the best way to write [0..100] in C#?

What's the best way to write [0..100] in C#? I'm trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range. Here's an example: ``` IEnum...

11 Oct at 16:46

Free optimization library in C#

Free optimization library in C# Is there any optimization library in C#? I have to optimize a complicated equation in excel, for this equation there are a few coefficients. And I have to optimize them...

1 Sep at 01:22

Unused using statements

Unused using statements I may already know the answer to this question, but I thought it was worth asking anyway. If I have a load of `using` statements within my code file that being used; 1. Does t...

17 Jun at 12:13

How to disable compiler optimizations in gcc?

How to disable compiler optimizations in gcc? I am trying to learn assembly language. I have searched and found how to disassemble a `.c` file but I think it produces some optimized version of the pro...

Big O, how do you calculate/approximate it?

Big O, how do you calculate/approximate it? Most people with a degree in CS will certainly know what [Big O stands for](http://www.nist.gov/dads/HTML/bigOnotation.html). It helps us to measure how wel...

Getting all types that implement an interface

Getting all types that implement an interface Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations? This is what I ...

{version} wildcard in MVC4 Bundle

{version} wildcard in MVC4 Bundle In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder. In the example below what does `-{version}` mean?

How do I run nGen at the end of the installation (MSI)?

How do I run nGen at the end of the installation (MSI)? I would like to execute nGen at the end of my installation simply to improve the perceived performance of the first startup of my application. H...

How to interpret loss and accuracy for a machine learning model

How to interpret loss and accuracy for a machine learning model When I trained my neural network with Theano or Tensorflow, they will report a variable called "loss" per epoch. How should I interpret ...

Resharper redundant 'else' really redundant?

Resharper redundant 'else' really redundant? Resharper is telling me that the 'else' in this code is redundant: The `else` does not seem redundant because the `else` keeps `b` from being evaluated if ...

14 Nov at 23:17

How to get the maximum number of a particular length

How to get the maximum number of a particular length I have a number, for example 1234567897865; how do I max it out and create 99999999999999 ? I did this this way: ``` int len = ItemNo.ToString().Le...

29 Mar at 17:19

Different ways of adding to Dictionary

Different ways of adding to Dictionary What is the difference in `Dictionary.add(key, value)` and `Dictionary[key] = value`? I've noticed that the last version does not throw an `ArgumentException` wh...

4 Dec at 09:32

More efficient ways of doing this

More efficient ways of doing this vr_world.getNodeNames() returns me a gigantic list, vr_world.getChild(i) returns a specific type of object. This is taking a long time to run, is there anyway to make...

7 Oct at 19:51

List<T>.RemoveAll() efficiency / compiler optimisation

List.RemoveAll() efficiency / compiler optimisation Regarding efficiency, does anyone know if the compiler is clever enough to create the array containing `1, 3, 5` for each iteration of the loop in t...