В ответ на тему от Бирдяя на тему меряния пип^W компиляторами. Меряемся языками. Задача - расчет интеграла от x^2 методом трапеций. ********************************************************************** Претендент первый - pure C: [annoynimous@node6 birdie-sucks]$ cat 1Dint.c #include<stdio.h> #include<math.h> #define eps 1e-7 double square (double x) { return x * x; }; double integrate (double a, double b, double (*integrand) (double x)) { if (fabs (b - a) < eps) { return integrand ((a + b) / 2.) * (b - a); } else { return (integrate (a, (a + b) / 2., integrand) + integrate ((a + b) / 2., b, integrand)); }; } int main (void) { printf ("%18.15f\n", integrate (0., 1., square)); return 0; } [annoynimous@node6 birdie-sucks]$ [annoynimous@node6 birdie-sucks]$ gcc -O2 -ffast-math 1Dint.c -o 1Dint [annoynimous@node6 birdie-sucks]$ time ./1Dint 0.333333333333333 real 0m0.617s user 0m0.534s sys 0m0.001s [annoynimous@node6 birdie-sucks]$ ********************************************************************** Претендент второй - Guile: [annoynimous@node6 birdie-sucks]$ cat 1Dint.lsp #!/usr/bin/guile -s !# (define eps 1e-7) (define (mid-point a b) (/ (+ a b) 2.0)) (define (int a b f) (if (< (abs (- b a)) eps) (* (f (mid-point a b)) (- b a)) (+ (int a (mid-point a b) f) (int (mid-point a b) b f)))) (display (int 0. 1. (lambda (x) (* x x)))) (newline) [annoynimous@node6 birdie-sucks]$ [annoynimous@node6 birdie-sucks]$ time ./1Dint.lsp 0.333333333333333 real 1m19.748s user 1m13.086s sys 0m0.117s [annoynimous@node6 birdie-sucks]$ Получаем, что С быстрее в 129 раз. Вывод делаем сами. :) ЗЫ. Все совпадения, найденные в тексте - случайны.
←
1
2
→


Ответ на:
комментарий
от Bioreactor

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от annoynimous


Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от annoynimous


Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от anonymous


Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от Legioner


Ответ на:
комментарий
от zort

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от DemonZLa

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от DemonZLa

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от Deleted

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от zort


Ответ на:
комментарий
от klalafuda

Ответ на:
комментарий
от Legioner

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от birdie

Ответ на:
комментарий
от zort

Ответ на:
комментарий
от annoynimous

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от birdie

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум gcc всё-таки не очень sucks (2007)
- Форум getrusage (2008)
- Форум [C] Изменение кода в рантайме (2011)
- Форум [наблюдение] bash vs ELF (2007)
- Форум Почему такой разброс? (2020)
- Форум Двумерный массив из одномерного - ван секонд фастер вжуух. (2022)
- Форум [бенчмарк] С++ медленне С в 5 раз при уже при 0.1% кидаемых исключений [ЧЯДНТ ?] (2009)
- Форум gcc/g++ и мертвый код (2010)
- Форум Программирование alsa (не могу добиться нормального звука) (2010)
- Форум Программирование, ALSA (2010)