|
I wouldn't recommend assembly, unless platform portability is not a concern. A relatively easier option would be to apply a Duff's device to this loop. Unrolling the loop can provide performance boost. However, unless this is, say DSP code that has to run over and over again its probably not worthwhile and the effects wont be noticable.
http://en.wikipedia.org/wiki/Duff%27s_device[^]
I would recommend to benchmark the code first to establish the base data for performance comparison.
|
|
|
|
|
prime_tang wrote: but due to the design of my application, it requires many times to use this algorithm
First step would of course be to find a design that doesn't require many uses.
That would have a far more significant impact on any speed up of the actual algorithm.
|
|
|
|
|
I don't see much optimization potential in your function that a decent compiler won't apply already.
That said, the first question you should ask: is there an actual performance bottleneck? Have you measured the time your application takes, and is it really too slow for your purposes?
Second question: if there is a performance issue, which function is causing it? Maybe there are others called alongside this function that take more time and have more optimization potential? Typically, I/O is the slowest part of any application, so reducing I/O to the absolute minimum could already help.
You say it is called often, so the next question would be: can you reduce the number of calls? You said the number of calls is high due to your application design, this implies a different design would require less calls?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hi
I have a Console C project that has a number of DLL's
I got the following error when linking
Quote: error LNK2001: unresolved external symbol _DllMainCRTStartup@12
I am linking it as 64 bit
How would I know what .lib to include by googling seemed it was MSVCRT.LIB
but that didn't resolve my problem
I remember once using dependency walker to resolve symbols but I think that was looking at .DLL to see what entry points were exposed
Thanks
|
|
|
|
|
|
Thank you again Richard the problem was in my win32.mak
I have amd64 cpu and for some reason win32 it was i386 thus generating @12 ordinal for
The DLL startup entry point
still trying to finish building
|
|
|
|
|
So I was right 64bits objs and 32bits linking...
|
|
|
|
|
|
If you are linking for 64bits the entry point for dll should be _DllMainCRTStartup (undecorated entry point). If you get this error probably there is a error in linker switches because it seems that you are trying to use 64 bits objects in a 32bits link.
It is not very clear in which part of your project you're getting the error: compiling the console exe or one of the DLL?
modified 22-Mar-15 6:58am.
|
|
|
|
|
SIR,
I want to define my own malloc function in c++ using new operator..
|
|
|
|
|
Thanks for the warning. Good luck.
|
|
|
|
|
and the question is?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
A very simple and realistically non-worthwhile implementation is simple. Your malloc calls new with an byte array. Then your free, which you would also implement would use delete to delete the array.
If you want a learning experience however then you should do the following in the specified order.
1. Learn what stack and list are and how to implement them.
2. Specifically learn how to implement them using sequential memory and not just pointers.
3. Learn how malloc is generally implemented. You will need substantial understanding of 1/2 to understand this.
4. Implement your own heap management. (Which you will understand after doing 1/2/3.)
|
|
|
|
|
I never use VC++ to develop an app that use to connect and update database before.
My app is design to allow user to update the database by supply MS Excel file.
When the app open, user need to choose either connect to MS Access 2010 (.mdb) or MSSQL 2014 express.
By using MFC Application Wizard, I need to choose which client type to use at Database support section (ODBC or OLEDB).
After reference to the doc on the web. Seems that OLEDB suitable for Access and ODBC suitable for MSSQL.
This make me has a difficulty to choose between them during start.
Or I should create a project that has no database support at start, then add DLL that support database to this solution later.
But the wizard that use to create MFC DLL and ATL Project has no section for choose database support.
Any advice and suggestion that direct me how to start is appreciated.
|
|
|
|
|
There are no limitations to support different types of databases in one application. The application wizard only prepares the project to support a specific database interface. Support for other interfaces can be added later manually.
My suggestion:
Create two new empty projects with support for different database interfaces. Then choose one as your project and add the necessary definitions from the created source files of the other project by comparing the files.
|
|
|
|
|
Thanks for reply.
Since wizard can relief my work. I just think is it possible to select both ODBC and OLEDB by using wizard.
If it is not possible, I have to implement the code myself.
That's hell a lot of work
|
|
|
|
|
The selection uses radio buttons. So only one can be selected.
You must write the code to access the database anyway. The wizard will not do that. It just prepares your project. Merging two empty projects into one is not much work.
|
|
|
|
|
Note that reading even a trivial excel file in an application can be a difficult task.
Once you have read the data the user interface and writing to a database is easier because there are more sources that one can learn from.
|
|
|
|
|
I added one extra "copy path" option in windows 7 context menu using regedit ...
when I right click on any file and select "copy path" option the path of that file should get copied to txt file
plz help me out ....I m working on one project where I need this...
|
|
|
|
|
What is the C/C++/MFC question here?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
|
When read big excel file, it takes many time to read cell one by one.
|
|
|
|
|
|
I'm Using Library for Office
// Loop through the data and report the contents.
for (int rowCounter = 1; rowCounter <= iRows; rowCounter++) {
for (int colCounter = 1; colCounter <= iCols; colCounter++) {
index[0]=rowCounter;
index[1]=colCounter;
COleVariant vData;
saRet.GetElement(index,vData);
CString szdata(vData);
valueString += szdata;
valueString += "\t";
}
valueString += "\r\n";
}
In this example, it's using loop to read cells, the reading speed is not good.
|
|
|
|
|
Which library?
lichengbyd wrote: In this example, it's using loop to read cells, the reading speed is not good. It is using the loops to extract the values from the safe array. But the data are already in memory of your application. You missed the call that retrieves the data from Excel:
COleSafeArray saRet(oRange.get_Value(covOptional));
|
|
|
|