I want to write a function that returns the nearest upper power of 2 number. For example if my input is 789, the output should be 1024. Is there any way of achieving this without using any loops but just using some bitwise operators?
...
Part of the system I'm working on at the moment involves a log in mysql, with counts being frequently updated.
The data being inserted is of the format:
date | name | count |
-----------+------+-------+
2009-01-12 | alan | 5 |
2009-01-12 | dave | 2 |
2009-01-12 | mary | 1 |
This data is parsed regularly from a flat ...
I know this is probably general, please bear with me!
We've got a program that uses a web camera and, based on what the camera is seeing, runs certain functions. The program runs excellently on MacOS and Linux, and it compiles and it does run on Windows, but a couple of the functions, (including one that iterates pixel by pixel, 640x480...
I've been getting my hands dirty lately working on development for the iPhone. Development on this platform adds (and on others I am sure) considerations that are not there when developing for desktop computers
Battery life (need to keep cpu/network or any hardware usage to a min to preserve battery life)
Reducing Network traffic (most...
I am developing a small intranet based web application. I have YSlow installed and it suggests I do several things but they don't seem relevant for me.
e.g I do not need a CDN.
My application is slow so I want to reduce the bandwidth of requests.
What rules of YSlow should I adhere to?
Are there alternative tools for smaller sites?
Wh...
Just wondering if anyone knew off the top of their heads if there was much difference in doing the following:
String wibble = "<blah> blah blah </blah>.... <wibble> blah wibble blah </wibble> some more test here";
int i = wibble.lastIndexOf(">");
int j = wibble.lastIndexOf('>');
...
How much of a bottleneck is memory allocation/deallocation in typical real-world programs? Answers from any type of program where performance typically matters are welcome. Are decent implementations of malloc/free/garbage collection fast enough that it's only a bottleneck in a few corner cases, or would most performance-critical softw...
I come from a DBA world and performance has always been an obsession. I am turning to development and I always think about performance, constantly, all the time.
Reading on SO sometimes seems that performance does not matter. For instance for evangelists on hibernate (or any other ORM).
As a developer, when do I have to think about per...
I know think that I've read that one of the following is faster than the other, but I forget which is which:
SELECT * FROM `myTable` WHERE `myDate` > NOW();
SELECT * FROM `myTable` WHERE NOW() < `myDate`;
...
I've played with boost::pool a few times in places where it seemed to me I was seriously hammering the heap with a lot of object "churn". Generally I've used boost::object_pool, or boost::pool_alloc as an STL template parameter. However the result is invariably that performance is virtually unchanged, or significantly worsened.
I'm cu...
I have a search query that I'm inheriting and attempting to optimize. I am curious to hear if anyone has any best practices and recommendations for such. The production server is still SQL Server 2000 also.
The query is an advanced customer search stored procedure that accepts 5 different search criteria parameters (i.e. first name, la...
How do you do "inline functions" in C#? I don't think I understand the concept. Are they like anonymous methods? Like lambda functions?
...
If you are developing a memory intensive application in C++ on Windows, do you opt to write your own custom memory manager to allocate memory from virtual address space or do you allow CRT to take control and do the memory management for you ? I am especially concerned about the fragmentation caused by the allocation and deallocation of ...
Anyone who reads a lot of SO questions knows that the need to preach against premature optimization is not going away anytime soon - but what about the other extreme, the projects that fail or struggle because they did not consider performance early enough?
Should you just try and get a working system as quickly as possible so you can d...
Is there any tool that lists which and when some classes are effectively used by an app or, even-better, automatically trims JAR libraries to only provide classes that are both referenced and used?
...
Hi, I was wondering if it which is faster when trying to, for example, check how many posts are in a particular thread on a forum. Should I...
(a) Go through each post in the database with the particular thread ID, and count how many rows
or
(b) Add one to a separate column in the threads database every time a thread is made, and then...
I'm using Visual Basic 9 (VS2008) and TagLib.
The following code extracts the album art from an MP3 file and displays it in a PictureBox.
Is there a better way to write this code?
Dim file As TagLib.File = TagLib.File.Create(filepath)
If file.Tag.Pictures.Length >= 1 Then
Dim bin As Byte() = DirectCast(file.Tag.Pictures(0).Data...
I've been informed that my library is slower than it should be, on the order of 30+ times too slow parsing a particular file (text file, size 326 kb). The user suggested that it may be that I'm using std::ifstream (presumably instead of FILE).
I'd rather not blindly rewrite, so I thought I'd check here first, since my guess would be the...
I love recursion. I think it simplifies things a lot. Another may disagree; I think it also makes the code a lot easier to read. However, I've noticed that recursion is not used as much in languages such C# as they are in LISP (which by the way is my favorite language because of the recursion).
Does anybody know if there is any good re...
In my C# application, I have a large struct (176 bytes) that is passed potentially a hundred thousand times per second to a function. This function then simply takes a pointer to the struct and passes the pointer to unmanaged code. Neither the function nor the unmanaged code will make any modifications to the struct.
My question is, sho...