Using a site like StackOverflow as an example:
I have a table of users, questions, and user-questions mappings. My user-questions mappings table looks like this:
userID (int 8)
questionID (int 8)
When displaying a list of popular questions, I am trying to mark the questions that have been posed by the logged-in user. Is it more effic...
I've a blog where I run third party ads and I refer them from my page similar to following format
http://www.<advertising_network>.com/delivery/fp?u=<username>&i=<adv>_region_11111&z=11111&n=3
If I want to show these ads at three places I have to place three such lines on my code and then browser makes th...
I have a probability problem, which I need to simulate in a reasonable amount of time. In simplified form, I have 30 unfair coins each with a different known probability. I then want to ask things like "what is the probability that exactly 12 will be heads?", or "what is the probability that AT LEAST 5 will be tails?".
I know basic pr...
I'm using various boolean flags in my tables, and from reading a bit about optimizing performance I came across a widespread tip to avoid using boolean flags.
What are the effective alternatives? Some examples would be much appreciated.
...
I have a CherryPy app that dynamically generates images, and those images are re-used a lot but generated each time. The image is generated from a querystring containing the variables, so the same query string will always return the same image (until I rewrite the generation code) and the images are not user-specific.
It occurred to me ...
I'm building an iPhone application using Xcode 3.2.3 and I have experienced very weird behavior of the application when run in Release/Distribution Configuration. Let show the code first:
- (NSTimeInterval) durationValue {
NSTimeInterval duration = 0.0;
if (!self.startDateTime) {
return 0.0;
}
NSDate *lateDate = self.endDateTime...
Hi everyone,
I have a UNION query consisting of two fast queries.
( SELECT DISTINCT ( SELECT strStatus FROM User_User_XR uuxr WHERE ( uuxr.intUserId1 = '1' AND uuxr.intUserId2 = u.intUserId ) ) AS strFriendStatus1, uuxro.strStatus AS strFriendStatus2, uuxr.intUserId2 AS intUserId, u.strUserName , u.strGender, IF( u.dtmBirth != '0000-00...
The following testing code does correctly in VS either with debug or release, so does it in gcc. It also does correctly for ICC with debug, but not when optimization enabled (-O2).
#include <cstdio>
class tClassA{
public:
int m_first, m_last;
bool isEmpty() const {return (m_first == m_last);}
void updateFirst() {m_first = m_f...
I'm having a buffered image with lot of small square's(grid).This image is created based on a user selected background image.If the selection is small the image appears fast.But if the selection is a large then memory overflow happen even if set to 1GB.
The code for buffered image is like this:
mainMap = new BufferedImage(width, height,...
In Rails while using activeRecord why are join queries considered bad.
For example
Here i'm trying to find the number of companies that belong to a certain category.
class Company ActiveRecord::Base
has_one :company_profile
end
Finding the number of Company for a particular category_id
number_of_companies = Company.fin...
I have a rails app which shows the following log for a single action
Completed in 587ms (View: 415, DB: 29) | 200 OK [http://localhost/]
its taking 415 ms to render the view layer. Is there any way to optimize view rendering in rails ?
I am a beginner in ruby on rails.
I have render call like this on a page(written in HAML) that show...
Hey Everybody!
So i've had JQGrid in my application for a while now and the speed of the grid hasnt really bothered me up until I started optimization.
If find that even if I have a small grid (20 items per page) the hover highlighting is slow and if the grid happens to need a scroll bar on the page, the scrolling of the page is really...
Rather, is there a way to tell if it's been compiled with the optimization parameter enabled or disabled. I don't want to know if it's release or debug, since either can be enabled with or without optimizations. From my perspective, even though the code says it's release version, is it truly optimized? Thanks.
...
I have this query below that I've rewritten a dozen different ways, yet I am unable to get it optimized and loaded in under 8 seconds. If I can get it to 2s, that would be good. 1s or less would be optimal.
This query retrieves a list of books that are currently available for sale or trade, and performs a bit of filtering. This query...
Are there any compilers in use that pay little attention to compilation speed but rather seek maximum optimization even at an order(s) of magnitude compile time slow down?
It seems to me that having a compile take hours/days vs minutes/second wouldn't be a major issue once you get very near the final release. (And if you have enough tes...
I'm making a simple RTS game. I want it to run very fast because it should work with thousands of units and 8 players.
Everything seems to work flawlessly but it seems the line of sight calculation is a bottleneck. It's simple: if an enemy unit is closer than any of my unit's LOS range it will be visible.
Currently I use a quite naive ...
What would be the benefits of inlining different types of function and what are the issues that would I would need to watch out for when developing around them? I am not so useful with a profiler but many different algorithmic applications it seems to increase the speed 8 times over, if you can give any pointers that'd be of great use to...
Ok, so I swear this question should be all over the place, but its not.
I have a value object, inside are lots of getters/setters. It is not a dynamic class. And I desperately need to search an ArrayCollection filled with them. The search spans all fields, so and there are about 13 different types of VOs I'll be doing this with.
I've t...
Suposse I have the next MySQL database with 500.000 rows:
users
{
id - int,
name - varchar(32),
verified - tinyint(1)
}
primary { id }
index { verified }
And I need to get last 20 not verified users, so I use the next query:
SELECT * FROM users WHERE verified != 1 ORDER BY id DESC LIMIT 20
But it takes 1...
Hello, I'm trying to solve a problem (in php, but programming language doesn't matter).
I'm having a n number of persons that have paid money, and I have got a m number of persons that are going to pay the same amount as the sum of what the n number of people have paid.
I want to calculate the shortest route of money transfers between th...