473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Computing Fibonacci numbers as a performance testsuite

An algorithm which computes very long Fibonacci numbers
http://groups.google.com/groups?selm....uni-berlin.de
was used as a performance testsuite
to compare speed of the code produced by various compilers.
=============== =============== =============== ==============
Windows 2000 Professional Ver 5.0 Build 2195 Service Pack 2
Intel(R) Celeron(R) CPU 1.70 GHz
GNU time 1.7 (to get the real time used)
=============== =============== =============== ==============
A. Real and processor time used to compute Fibonacci[10000] and Fibonacci[25000].

Here are summary results.

|============== =============== =============== =============
| | Opt | Fib-10000 | Fib-25000 |
| Compiler | Lev |-------------|-------------|
| | | Real : CPU | Real : CPU |
|============== =============== =============== ============|
| GNU gcc compiler |
|--------------------------------------------------------|
| g++ 3.3.1 (Cygwin) | No | 0.45 : 0.41 | 1.86 : 1.81 |
| | O1 | 0.28 : 0.24 | 1.03 : 0.99 |
| | O2 | 0.27 : 0.23 | 1.02 : 0.98 |
| | O3 | 0.27 : 0.24 | 1.02 : 0.98 |
| | | : | : |
| g++ 3.3.1 (Cygwin) | No | 0.33 : 0.30 | 1.59 : 1.56 |
| Mingw32 interface | O1 | 0.20 : 0.16 | 0.87 : 0.84 |
| | O2 | 0.19 : 0.16 | 0.85 : 0.82 |
| | O3 | 0.19 : 0.16 | 0.85 : 0.82 |
| | | : | : |
| gpp 3.2.1 (DJGPP) | No | 0.37 : 0.24 | 1.99 : 1.92 |
| | O1 | 0.20 : 0.11 | 1.15 : 1.05 |
| | O2 | 0.19 : 0.11 | 1.08 : 0.99 |
| | O3 | 0.19 : 0.11 | 1.08 : 0.99 |
| | | : | : |
|--------------------------------------------------------|
| Digital Mars C/C++ Compiler, STLport 4.5.3 |
|--------------------------------------------------------|
| Version 8.35n | - | 0.20 : 0.16 | 0.84 : 0.80 |
| | | : | : |
| Version 8.36.4n | - | 0.20 : 0.16 | 0.84 : 0.80 |
|============== =============== =============== =============

B. The names of DLL files on which the programs depend :

* g++ 3.3.1 (Cygwin)
------------------
C:\cygwin\bin\c ygwin1.dll
C:\WINNT\System 32\KERNEL32.dll
C:\WINNT\System 32\NTDLL.DLL
* g++ 3.3.1 (Cygwin, Mingw32 interface)
-------------------------------------
C:\WINNT\System 32\msvcrt.dll
C:\WINNT\System 32\KERNEL32.dll
C:\WINNT\System 32\NTDLL.DLL
* gpp 3.2.1 (DJGPP)
-----------------
Unknown
* Digital Mars C/C++ 8.35n
------------------------
C:\WINNT\System 32\KERNEL32.DLL
C:\WINNT\System 32\NTDLL.DLL
C:\WINNT\System 32\USER32.DLL
C:\WINNT\System 32\GDI32.DLL

C. Notes.
Note-1. The main() program in
http://groups.google.com/groups?selm....uni-berlin.de
was slightly changed to get the processor time used.

// ------ Updated main() : BEGIN ------
#include <time.h> // Added
int main (int argc, char **argv)
{
const string option (check (argc, argv));
if (option.empty() )
{
usage (argv);
return 1;
}

const uint N = atoi (argv[2]);

const clock_t clock_start = clock(); // Added
assert (clock_start != clock_t (-1)); // Added

if (option == ALL_FIBS)
{
Fibonacci fib(N);
fib.show_all_nu mbers();
}

if (option == TH_FIB)
{
Fibonacci fib(N);
fib.show_last_n umber();
}

if (option == SOME_FIBS)
{
Fibonacci fib;
for (int i = 2; i < argc; i++) fib.show_number (atoi(argv[i]));
}

if (option == RAND_FIBS)
{
const int max_rand_fib = (argc == 3) ? MAX_RAND_FIB : atoi (argv[3]);
Fibonacci fib;
for (uint i = 0; i < N; i++) fib.show_number (rand()%max_ran d_fib);
}

// ------ Added : BEGIN ------
const clock_t clock_end = clock();
assert (clock_end != clock_t (-1));

cerr << "CPU time used : " << (double (clock_end - clock_start)/CLOCKS_PER_SEC) << " sec" << endl;
// ------ Added : END --------

return 0;
}
// ------ Updated main() : END --------

Note-2. To get the real time used the time() utility was used.

D. Comment.
It seems that there is some inconsistency between real-time and CPU-time
while computing Fibonacci [10000] through the DJGPP gpp compiler :
CPU-time is too small with regard to real-time.
Probably that might be caused by too small CLOCKS_PER_SEC value (91).
Note. In Cygwin, MinGW, Digital Mars : CLOCKS_PER_SEC = 1000.

--
=============== =============== =======
Alex Vinokur
mailto:al****@c onnect.to
http://mathforum.org/library/view/10978.html
news://news.gmane.org/gmane.comp.lang.c++.perfometer
=============== =============== =======


Jul 19 '05 #1
0 2341

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
13114
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers, and when the numbers get too large it maxes out the int and I can't count any higher. I am trying to use extremely large numbers, I would like to use up to 10^50 or so. So my question is how do I do this? I'm just learning the language and I...
0
1436
by: Alex Vinokur | last post by:
One more improvement has been done in the "Computing very large Fibonacci numbers" algorithm. Its new version can be seen at http://groups.google.com/groups?selm=2mk62rFo1mv0U1%40uni-berlin.de Iterators in the transform() algorithm have been replaced by pointers. --------------------------------------
0
2667
by: Alex Vinokur | last post by:
=================================== ------------- Sorting ------------- Comparative performance measurement =================================== Testsuite : Comparing Function Objects to Function Pointers Source : Technical Report on C++ Performance Tool : The C/C++ Program Perfometer (Version 2.8.1-1.19-Beta) * http://sourceforge.net/projects/cpp-perfometer/
5
7743
by: Niks | last post by:
Can anybody explain me what is a "Fibonacci search"? even an URL will do. Thanks for reading.
4
4858
by: YS Sze | last post by:
If you know the exact longitude and latitude for a specific location, would anyone think it'd make any sense to find out if this set of location numbers is really part of the Fibonacci series or not? Or, another way to look at this is that: Would anyone of you think it is worth a while to find out if there is any location on earth with the set of longitude and latitude numbers that coincides with the Fibonacci series? As I see it, if...
62
5442
by: jugaaru | last post by:
How to generate fibonacci mubers in C ?
13
3171
by: mac | last post by:
Hi, I'm trying to write a fibonacci recursive function that will return the fibonacci string separated by comma. The problem sounds like this: ------------- Write a recursive function that creates a character string containing the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) = F(1) = 1 -, separated by comma. n should be given as an argument to the program. The recursive function should only take one parameter, n, and...
6
4975
by: Andrew Tatum | last post by:
I'm having some problems with the below equation. I have no problems when it comes to positives. Negatives create the problem.. C 2 1 4 However, this doesn't work:
8
3192
by: help2008 | last post by:
Hi I have been doing this working on an assignment for the last week and have stumbled across a part which I cant get my head around. I was hoping that someone could explain what I am missing. I do not expect you to do my work for me. I have completed the rest of the assignment and I am just stuck here (at the very end). Here is my problem. "I have to find out the decimal values of the ratios of consecutive fibonacci numbers." As I said...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.