performance

C#: What is the fastest way to generate a unique filename?

I've seen several suggestions on naming files randomly, including using System.IO.Path.GetRandomFileName() or using a System.Guid and appending a file extension. My question is: What is the fastest way to generate a unique filename? ...

Included file from header/source file

What is the difference between including a file from a header file or from a source file in C++ in regards to performance during compilation? What are the reasons to include files in the source file and not in the header file (except when absolutely required)? Does the one (header) affect compile time and the other (source file) affect...

Performance of java on different hardware?

In another SO question I asked why my java programs run faster on AMD than on Intel machines. But it seems that I'm the only one who has observed this. Now I would like to invite you to share the numbers of your local java performance with the SO community. I observed a big performance difference when watching the startup of JBoss on di...

Indexing Performance BigInt vs VarChar

This is a FACT Table in a Data Warehouse It has a composite index as follows ALTER TABLE [dbo].[Fact_Data] ADD CONSTRAINT [PK_Fact_Data] PRIMARY KEY CLUSTERED ( [Column1_VarChar_10] ASC, [Column2_VarChar_10] ASC, [Column3_Int] ASC, [Column4_Int] ASC, [Column5_VarChar_10] ASC, [Column6_VarChar_10] ASC, [C...

Performance penalty with executing x86 instructions stored in the data segment?

Hi. I have a simple program that first writes some native x86 instructions into a declared buffer, and then sets a function pointer to this buffer and makes a call. I'm noticing a severe performance penalty, however, when that buffer is allocated on the stack (as opposed to on the heap, or even in the globals data area). I verified th...

Adding a key & value to all arrays within an array

Hey all, I would like to take this: $arr = array( array("top"=>10, "left"=>10), array("top"=>50, "left"=>30), array("top"=>60, "left"=>70) ); Run a function and have the result be: array( array("top"=>10, "left"=>10, "width"=>400), array("top"=>50, "left"=>30, "width"=>400), array("top"=>60, "left"=>70, "width"=>40...

Is there a peformance difference between jquery selector or a variable

Lately i have been wondering if there is a performance difference between repeating the selector just over and over again or just using a var and store the selector in that and just refer to it. $('#Element').dothis(); $('#Element').dothat(); $('#Element').find('a').dothat(); or just var Object = $('#Element'); Object.dothis(); O...

std::pair<int, int> vs struct with two int's

In an ACM example, I had to build a big table for dynamic programming. I had to store two integers in each cell, so I decided to go for a std::pair<int, int>. However, allocating a huge array of them took 1.5 seconds: std::pair<int, int> table[1001][1001]; Afterwards, I have changed this code to struct Cell { int first; int s...

Making simple performance modifications to an already compiled jar?

Like many log4j users, we often have debug level logging that is expensive to evaluate. So we guard those cases with code like: if( _logger.isDebugEnabled ) _logger.debug("Interesting, my foojes are goofed up: " + getFullDetails()) However, that is uglier than a plain _logger.debug call, and sometimes the programmer doesn't realize...

Static Access to HashMap/Array?

Here's an example of a static method that is used in a web application. As you can see, the String[] allergensArr gets insantiated each time that this method is called. It's threadsafe since it's in a static method but it's an expensive call. What are some other ways that the allergensArr[] can be used so that it's not instantiat...

WCF ConcurrencyMode.Multiple Connection best practices and Caching

I've got a WCF service with the following settings: NetNamedPipeBinding ConcurrencyMode.Multiple InstanceContextMode.Single Now I've got a client that accesses to this WCF service in a multi-threaded fashion. As far as I understand I have to open a new connection to the service for each thread to avoid threads to block each others. ...

How does .NET/Mono performance compare to JVM?

I've been wondering this for a while. Please give quantitative data to support your answer. Related: Is there a significant difference between Windows, Mac, and linux JVM performance? ...

Overhead costs of opening a file handle in PHP?

I'm writing a logging tool which writes messages to a file, and I'm not sure of the best way to deal with the file pointer. I'm tossing up between these two methods: // Open, Write, Close; Open, Write, Close... function write($message) { $fh = fopen('file.log', 'a'); fwrite($fh, $message . "\n"); fclose($fh); } // OR ----- ...

Getting a list of child entities in App Engine using get_by_key_name (Python)

My adventures with entity groups continue after a slightly embarrassing beginning (see Under some circumstances an App Engine get_by_key_name call using an existing key_name returns None). I now see that I can't do a normal get_by_key_name call over a list of entities for child entities that have more than one parent entity. As the Mode...

Performance debugging network throughput of minimal Winsock2 app

I have a very simple Winsock2 TCP client - full listing below - which simply blasts a bunch of bytes. However, it's running very slowly over the network; the data just trickles by. Here's what I've tried and found (both Windows PCs are on the same LAN): Running this app from one machine to the other is slow - it takes ~50s to send 8MB...

What's wrong with mark-and-sweep GCs?

I'm reading Steve Yegge's "Dynamic Languages Strike Back" talk, and in it he sort of criticizes mark-and-sweep GCs (about 5-10 percent through that link, the "Pigs attempt's to fly" slide) What's wrong with them? ...

Tool or formula for calcuating man-hours required for a project

Is there a tool or a formula for calculating man-hours required for a certain project? Either by specifying the details, either, even better, input the sources and have it calculate a measure of how many man-hours were put into the project. Edit: I often hear about big projects, with components built in parallel by numerous groups, tha...

To cache or not to cache - GetCustomAttributes

Hi, I currently have a function: public static Attribute GetAttribute(MemberInfo Member, Type AttributeType) { Object[] Attributes = Member.GetCustomAttributes(AttributeType, true); if (Attributes.Length > 0) return (Attribute)Attributes[0]; else return null; } I am wondering if it would be worthwhile cac...

String concatenation vs String Builder. Performance

I have a situation where I need to concatenate several string to form an id of a class. Basically I'm just looping in a list to get the ToString values of the objects and then concatenating them. foreach (MyObject o in myList) result += o.ToString(); The list is NOT expected to have more than 5 elements (although it could but that's...

Is there any problem using the '@' while writing the code

Is there any problem using the '@' while writing the code? and what is the mechanism behind it? ...