optimization

Can it be advantageous for a method to return IOrderedEnumerable<T> instead of IEnumerable<T>?

Can it be advantageous for a method to return IOrderedEnumerable instead of IEnumerable? ...

How many threads to create?

Hello everyone, I am just learning how to write mutithreaded programs right now and I have a hypothetical question about how many threads are optimal for a program. Let me describe 2 scenarios. The first scenario is that i have a program that is easily multi threaded but each thread is going to be doing a lot of work (execution time...

Very slow MYSQL query for 2.5 million row table

Hi, I'm really struggling to get a query time down, its currently having to query 2.5 million rows and it takes over 20 seconds here is the query SELECT play_date AS date, COUNT(DISTINCT(email)) AS count FROM log WHERE play_date BETWEEN '2009-02-23' AND '2020-01-01' AND type = 'play' GROUP BY play_date ORDER BY play_date desc; `id` ...

Problem with session in zend framework

Hello everyone. I am trying something in the zend Framework I have create a project with zend_tool. I have 2 controllers artist controler account controler Within the accountcontroller whenever the user login the $_SESSION['id'] is set to the user id. But as soon as I leave the accountcontroller and go to the Artist controller, m...

Are there better ways to overwrite a file then check for changes (in C#)?

Situation: I have a C# program which does the following: Generate many files (replacing the ones generated last time the program ran.) Read those files and perform a time-consuming computation. Problem: I only want to perform the time-consuming computation on files which have actually changed since the last time I ran the program. ...

Sub-query Optimization Talk with an example case

Hello guys, I need advises and want to share my experience about Query Optimization. This week, I found myself stuck in an interesting dilemma. I'm a novice person in mySql (2 years theory, less than one practical) Environment : I have a table that contains articles with a column 'type', and another table article_version that contain a...

Basic skills to work as an optimiser in the gaming industry

I'm curious about a certain job title, that of "senior developer with a specialty in optimisation." It's not the actual title but that's essentially what it would be. What would this mean in the gaming industry in terms of knowledge and skills? I would assume basic stuff like B-trees Path finding Algorithmic analysis Memory management ...

Speeding up self-similarity in an image

I'm writing a program that will generate images. One measurement that I want is the amount of "self-similarity" in the image. I wrote the following code that looks for the countBest-th best matches for each sizeWindow * sizeWindow window in the picture: double Pattern::selfSimilar(int sizeWindow, int countBest) { std::vector<int> ...

Optimising Searching of a 2-dimensional Array with LINQ

I have a 2-dimensional array of objects (predominantly, but not exclusively strings) that I want to filter by a string (sSearch) using LINQ. The following query works, but isn't as fast as I would like. I have changed Count to Any, which led to a significant increase in speed and replaced Contains by a regular expression that ignores ca...

about mysql index, multi-column or one?

I have a sql like this: SELECT * FROM tableA WHERE column_a = sth AND colun_b > sth so, how do I create index for it? One index for two column Two indexes for each column which is better? ...

Algorithm to find matching pairs in a list

I will phrase the problem in the precise form that I want below: Given: Two floating point lists N and D of the same length k (k is multiple of 2). It is known that for all i=0,...,k-1, there exists j != i such that D[j]*D[i] == N[i]*N[j]. (I'm using zero-based indexing) Return: A (length k/2) list of pairs (i,j) such that ...

Does a boolean condition in a for loop that is always false get optimized away?

I have the following situation bool user_set_flag; getFlagFromUser(&user_set_flag); while(1){ if(user_set_flag){ //do some computation and output } //do other computation } The variable user_set_flag is only set once and only once in the code, at the very start, its essentially the user selecting what he want...

Building optimized Qt4 - "./configure" flags and their meanings

Hey everyone, I recently followed a discussion on the Qt4-interest mailing list about whether it is legal or not to build a commercial/proprietary application and statically link Qt4 into it. While there are some non-proven ways of doing so (by providing object files and a Makefile, etc. to the customer), it doesn't sound like such a go...

How to efficiently use MySQLDB SScursor ?

Hi, I have to deal with a large result set (could be hundreds thousands of rows, sometimes more). They unfortunately need to be retrieved all at once (on start up). I'm trying to do that by using as less memory as possible. By looking on SO I've found that using SSCursor might be what I'm looking for, but I still don't really know how...

Why is squid good for REST architectures ?

In this article, it is argued that Use Memcache if you frequently fetch random entities from a database, and Squid if you use a REST architecture. Please explain why (with regard to Squid). ...

Reduce assembly number of instructions

I want to reduce (manually) the number of instructions from a Linux assembly file. This will be basically done by searching predefined reductions in an abstract syntax tree. For example: pushl <reg1> popl <reg1> Will be deleted because it makes no sense. Or: pushl <something1> popl <something2> Will become: movl <something1>,...

Does my C++ compiler optimize my code?

While using modern C++ compilers (including MSVC, GCC, ICC), how can I say if it has: parallelized the code vectorized the loops (or used other specific processor instructions) unrolled the loops detected tail-recursion performed RVO (return-value optimization) or optimized in some other way without diving into the assembler code the...

DOM vs Array - memory use

For example I have a list of 100 strings, and 100 span's with this strings. How do you think, how much span's takes more memory than array of strings. Is there possibility to measure? Is there optmisation to unvisible DOM? ...

SEO Optimization Error, improper crawling or improper indexing

hi, i have a blog build in wordpress, And my domain name is like example.com (i can't give you the original name, because some times the editors will mark this question as SPAM :( , and if any one really want to check directly from my site will add at the end of the question.) http://example.com and the blog name is http://example.com/...

Is it better/faster to have class variables or local function variables?

Ok I know the title doesn't fully explain this question. So I'm writing a program that performs a large number of calculations and I'm trying to optimize it so that it won't run quite so slow. I have a function that is a member of a class that gets called around 5 million times. This is the function: void PointCamera::GetRay(float x, fl...