optimization

Using BoneCP: Handling connections from the pool

此生再无相见时 提交于 2019-12-30 03:19:06
问题 I have just started using BoneCP and this is my first time using a connection pool. I'm somewhat confused as to how I am supposed to use it. Currently I am saving the BoneCP-object as a static variable, and thus I can use it between different connections. When I'm done with the connection, I close it with connection.close() . Should I do this, or should I not close it to enable it to be reused by the pool? This is my current implementation to get a connection: private static BoneCP

Read a line of input faster than fgets?

梦想与她 提交于 2019-12-30 03:08:27
问题 I'm writing a program where performance is quite important, but not critical. Currently I am reading in text from a FILE* line by line and I use fgets to obtain each line. After using some performance tools, I've found that 20% to 30% of the time my application is running, it is inside fgets . Are there faster ways to get a line of text? My application is single-threaded with no intentions to use multiple threads. Input could be from stdin or from a file. Thanks in advance. 回答1: You don't say

Face Detection on iPhone using OpenCV and LBP

感情迁移 提交于 2019-12-30 02:29:14
问题 I have been successfully working with the Haar algorithm in OpenCV-2.1.0 (cvHaarDetectObjects) to detect faces in pictures and video frames from within an Objective-C project for iOS 4.2. However, the processing time for the video frames still takes about 1-2 seconds on the iPhone 4 under most conditions. An example of the code I am using is given below: NSString *path = [[NSBundle mainBundle] pathForResource:@"haarcascade_frontalface_alt" ofType:@"xml"]; CvHaarClassifierCascade* cascade =

Need help using instancing in XNA 4.0

会有一股神秘感。 提交于 2019-12-30 02:26:27
问题 I have come to inquire about instancing in XNA I am a beginning XNA developer, only recently stepping up from 2D to 3D games. I'm trying to draw a large number of cubes made solely out of vertices in code. As one might suspect, drawing a large number of these cubes causes quite a bit of stress on my computer. As I was looking for a way to increase performance I came across the term "instancing". Not knowing how instancing works in XNA 4.0, I've looked around for a tutorial suitable for

java linkedlist slower than arraylist when adding elements?

一曲冷凌霜 提交于 2019-12-30 02:24:14
问题 i thought linkedlists were supposed to be faster than an arraylist when adding elements? i just did a test of how long it takes to add, sort, and search for elements (arraylist vs linkedlist vs hashset). i was just using the java.util classes for arraylist and linkedlist...using both of the add(object) methods available to each class. arraylist out performed linkedlist in filling the list...and in a linear search of the list. is this right? did i do something wrong in the implementation maybe

How can I speed up line by line reading of an ASCII file? (C++)

点点圈 提交于 2019-12-30 02:09:12
问题 Here's a bit of code that is a considerable bottleneck after doing some measuring: //----------------------------------------------------------------------------- // Construct dictionary hash set from dictionary file //----------------------------------------------------------------------------- void constructDictionary(unordered_set<string> &dict) { ifstream wordListFile; wordListFile.open("dictionary.txt"); std::string word; while( wordListFile >> word ) { if( !word.empty() ) { dict.insert

What kind of optimizations do both the C# compiler and the JIT do?

一曲冷凌霜 提交于 2019-12-30 02:04:25
问题 I'm continuing my work on my C# compiler for my Compilers Class. At the moment I'm nearly finished with the chapters on Compiler Optimizations in my textbook. For the most part, my textbook didn't have Just-In-Time compilation in mind when it was written and I'm curious about the kinds of static, pre-jit optimizations the C# compiler performs versus what it does during the JIT process? When I talk to people about compiling against the CLR, I typically hear things like, "Most of the

What kind of optimizations do both the C# compiler and the JIT do?

梦想的初衷 提交于 2019-12-30 02:04:08
问题 I'm continuing my work on my C# compiler for my Compilers Class. At the moment I'm nearly finished with the chapters on Compiler Optimizations in my textbook. For the most part, my textbook didn't have Just-In-Time compilation in mind when it was written and I'm curious about the kinds of static, pre-jit optimizations the C# compiler performs versus what it does during the JIT process? When I talk to people about compiling against the CLR, I typically hear things like, "Most of the

What kind of optimizations do both the C# compiler and the JIT do?

旧城冷巷雨未停 提交于 2019-12-30 02:04:05
问题 I'm continuing my work on my C# compiler for my Compilers Class. At the moment I'm nearly finished with the chapters on Compiler Optimizations in my textbook. For the most part, my textbook didn't have Just-In-Time compilation in mind when it was written and I'm curious about the kinds of static, pre-jit optimizations the C# compiler performs versus what it does during the JIT process? When I talk to people about compiling against the CLR, I typically hear things like, "Most of the

Integer division by 7

ε祈祈猫儿з 提交于 2019-12-30 02:00:07
问题 Source my answer in: Is this expression correct in C preprocessor I'm a little bit out of my forte here, and I'm trying to understand how this particular optimization works. As mentioned in the answer, gcc will optimize integer division by 7 to: mov edx, -1840700269 mov eax, edi imul edx lea eax, [rdx+rdi] sar eax, 2 sar edi, 31 sub eax, edi Which translates back into C as: int32_t divideBySeven(int32_t num) { int32_t temp = ((int64_t)num * -015555555555) >> 32; temp = (temp + num) >> 2;