Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <math.h>
- #include <iostream>
- #include <windows.h>
- using namespace std;
- int main()
- {
- LARGE_INTEGER timerFrequency, timerStart, timerStop;
- double a, b, x, d, f = 0, t, f1 = 0; double z = 1;
- char s;
- do
- {
- cout << "Enter the ranges of the interval: ";
- cin >> a;
- cin >> b;
- cout << "Enter the increment step: ";
- cin >> d;
- QueryPerformanceFrequency(&timerFrequency);
- QueryPerformanceCounter(&timerStart);
- for (x = a; x < b; x += d)
- f += (x*x) + cos(sqrt(x));
- //f += (cos(x - 1) / sin(x - 1)) * cos(x);
- cout << "f=" << f << endl;
- QueryPerformanceCounter(&timerStop);
- t = (double)(timerStop.QuadPart - timerStart.QuadPart) / (double)timerFrequency.QuadPart;
- printf("Time 1 is %lf seconds.\n", t);
- f = 0;
- _asm finit
- QueryPerformanceFrequency(&timerFrequency);
- QueryPerformanceCounter(&timerStart);
- for (x = a; x < b; x += d)
- {
- _asm {
- fld x
- fsqrt
- fcos
- fld x
- fmul x
- fadd
- fstp f
- /*fld x
- fsub z
- fcos
- fld x
- fsub z
- fsin
- fdiv
- fld x
- fcos
- fmul
- fstp f
- */
- }
- _asm fwait
- f1 += f;
- }
- cout << "f1=" << f1 << endl;
- QueryPerformanceCounter(&timerStop);
- t = (double)(timerStop.QuadPart - timerStart.QuadPart) / (double)timerFrequency.QuadPart;
- printf("Time ASM is %lf seconds.\n", t);
- cout << "Do you want to continue? y/n";
- cin >> s;
- } while (s != 'n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement