diff --git a/gnuplot/gnuplot.pdf b/gnuplot/gnuplot.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3ff8881440946a4c547aa774e198174262999f94 Binary files /dev/null and b/gnuplot/gnuplot.pdf differ diff --git a/gnuplot/plot.gp b/gnuplot/plot.gp new file mode 100755 index 0000000000000000000000000000000000000000..dc01ef4b343bea7557d60dc61180b06129c50935 --- /dev/null +++ b/gnuplot/plot.gp @@ -0,0 +1,55 @@ +#!/usr/bin/gnuplot -c +## set encoding iso_8859_15 +set encoding utf +set terminal qt persist +set grid +set style data point +set style function line +set style line 1 lc 3 pt 7 ps 0.3 +set boxwidth 1 +set xtics +set xrange ["0":] +set xlabel "N (bytes)" + +# +# ALTERNATIVA 1: Tabelas em arquivos separados (2 colunas) +# +set ylabel "<metrica 1>" +set title "<campo[marcador 1]>" +set terminal qt 0 title "<campo[marcador 1]>" +plot 'plot_exemplo-01.dat' title "<sem otimização>" with linespoints, \ + 'plot_exemplo-02.dat' title "<com otimização>" with linespoints + +pause -1 + +# +# ALTERNATIVA 2: Tabela com 3 colunas +# +set ylabel "<metrica 1>" +set title "<campo[marcador 1]>" +set terminal qt 1 title "<campo[marcador 1]>" +plot 'plot_exemplo-03.dat' using 1:2 title "<sem otimização>" with linespoints, \ + '' using 1:3 title "<com otimização>" with linespoints + +pause -1 + +# +# ALTERNATIVA 3: Função +# +set style function dots +set ylabel "<metrica 1>" +set title "<campo[marcador 1]>" +set terminal qt 2 title "<campo[marcador 1]>" +f(x,y) = cos(x)*cos(y) +splot f(x,y) title "easom" with dots + +pause -1 + +# Gerando figura PNG +set terminal png +set output "funcao__NxMetrica.png" +plot 'plot_exemplo-03.dat' using 1:2 title "<sem otimização>" with linespoints, \ + '' using 1:3 title "<com otimização>" with linespoints +replot +unset output + diff --git a/gnuplot/plot_exemplo-01.dat b/gnuplot/plot_exemplo-01.dat new file mode 100644 index 0000000000000000000000000000000000000000..80be8a97aa032c88f76a50600b4a4a2857c9ba46 --- /dev/null +++ b/gnuplot/plot_exemplo-01.dat @@ -0,0 +1,7 @@ +# Marcador "matPtrVet" +# n <METRICA 1> (sem otimização) +64 0.5 +100 50.433210629261 +128 25.798359943835 +2000 27.337482595053 +2048 18.873424079086 diff --git a/gnuplot/plot_exemplo-02.dat b/gnuplot/plot_exemplo-02.dat new file mode 100644 index 0000000000000000000000000000000000000000..d5c852b1b620a8975b0a50487ffd5704d8832612 --- /dev/null +++ b/gnuplot/plot_exemplo-02.dat @@ -0,0 +1,7 @@ +# Marcador "matPtrVet" +# n <METRICA 1> (com otimização) +64 0.5 +100 45.433210629261 +128 21.798359943835 +2000 21.337482595053 +2048 14.873424079086 diff --git a/gnuplot/plot_exemplo-03.dat b/gnuplot/plot_exemplo-03.dat new file mode 100644 index 0000000000000000000000000000000000000000..48cda506b929acc0ff78a9317b3a9c38e43175af --- /dev/null +++ b/gnuplot/plot_exemplo-03.dat @@ -0,0 +1,7 @@ +# Marcador "matRowVet" <METRICA 1> +# n sem_otimz. com_otimiz. +64 0.7 0.7 +100 50.433210629261 45.433210629261 +128 25.798359943835 21.798359943835 +2000 27.337482595053 21.337482595053 +2048 18.873424079086 14.873424079086 diff --git a/gnuplot/show3D.gp b/gnuplot/show3D.gp new file mode 100755 index 0000000000000000000000000000000000000000..dec7b48d0896de47a8d7ca3c95941f37aa650f2d --- /dev/null +++ b/gnuplot/show3D.gp @@ -0,0 +1,51 @@ +#!/usr/bin/gnuplot -c +## set encoding iso_8859_15 +set encoding utf +set terminal qt persist +set grid +set style data point +set style function dots +set style line 1 lc 3 pt 7 ps 0.3 +set boxwidth 1 +set xtics +set ytics +set ztics + +# +# EASOM +# +set xlabel "X" +set ylabel "Y" +set zlabel "Z" +set title "EASOM" +set terminal qt 0 title "EASOM" + +set xrange [0:6]; set yrange [0:6] +set style function dots +set isosamples 150,150; + +f(x,y) = cos(x) * cos(y) * exp(-(x - pi)**2 - (y - pi)**2) + +splot f(x,y) + +pause -1 + +# +# Styblinski-Tang +# +set xlabel "X" +set ylabel "Y" +set zlabel "Z" +set title "Styblinski-Tang" +set terminal qt 1 title "Styblinski-Tang" + +set xrange [-4:4]; set yrange [-4:4]; +set style function dots +set isosamples 150,150; + +f(x,y) = 80 + (x**4 - 16*(x**2) + 5*x + y**4 - 16*(y**2) + 5*y)/2 + +splot f(x,y) + +pause -1 + diff --git a/utils/sizeof_01.c b/utils/sizeof_01.c new file mode 120000 index 0000000000000000000000000000000000000000..3714ab253e4491b70eb0aea022604737346ebb1b --- /dev/null +++ b/utils/sizeof_01.c @@ -0,0 +1 @@ +/home/nicolui/.html/grad/Programas/C/sizeof_01.c \ No newline at end of file diff --git a/utils/sizeof_02.c b/utils/sizeof_02.c new file mode 120000 index 0000000000000000000000000000000000000000..15b0dbf3a3b49ae7c3e88c5a526cec90e7dce6fb --- /dev/null +++ b/utils/sizeof_02.c @@ -0,0 +1 @@ +/home/nicolui/.html/grad/Programas/C/sizeof_02.c \ No newline at end of file diff --git a/utils/sizeof_03.c b/utils/sizeof_03.c new file mode 100644 index 0000000000000000000000000000000000000000..7fb08649547bf3264cc88c799e6ffc1539fdf271 --- /dev/null +++ b/utils/sizeof_03.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> + +int main () +{ + + printf("%lu %lu %lu %lu %lu\n", sizeof(long long int), sizeof(long int), sizeof(int), sizeof(short int), sizeof(char)); + + return 0; + +} + diff --git a/utils/utils-00.c b/utils/utils-00.c new file mode 100644 index 0000000000000000000000000000000000000000..e712d67f3658502f8af37ce5a0ab0e1ef2390dd7 --- /dev/null +++ b/utils/utils-00.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include "utils.h" + +/* Retorna tempo em milisegundos + + Forma de uso: + + double tempo; + tempo = timestamp(); + <trecho de programa do qual se deseja medir tempo> + tempo = timestamp() - tempo; +*/ + +double timestamp(void) +{ + struct timeval tp; + gettimeofday(&tp, NULL); + // printf("\n*** %7.10lf ms %7.10lf ms\n", tp.tv_sec*1.0e3, tp.tv_usec*1.0e-3); + return((double)(tp.tv_sec*1.0e3 + tp.tv_usec*1.0e-3)); +} + diff --git a/utils/utils-00.h b/utils/utils-00.h new file mode 100644 index 0000000000000000000000000000000000000000..14a0ccece58b66243a5b8eade70a09b17154a8d1 --- /dev/null +++ b/utils/utils-00.h @@ -0,0 +1,10 @@ +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include <stdlib.h> +#include <sys/time.h> + +double timestamp(void); + +#endif // __UTILS_H__ + diff --git a/utils/utils-01.c b/utils/utils-01.c new file mode 100644 index 0000000000000000000000000000000000000000..69cbaf83e399b3638a37d2a4b34552bd869860ee --- /dev/null +++ b/utils/utils-01.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +#include "utils.h" + +/* Retorna tempo em milisegundos + + Forma de uso: + + double tempo; + tempo = timestamp(); + <trecho de programa do qual se deseja medir tempo> + tempo = timestamp() - tempo; +*/ + +double timestamp(void) +{ + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC_RAW, &tp); + return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6)); +} diff --git a/utils/utils-01.h b/utils/utils-01.h new file mode 100644 index 0000000000000000000000000000000000000000..594f595f918008a3e627d5df3c259c16d9110042 --- /dev/null +++ b/utils/utils-01.h @@ -0,0 +1,10 @@ +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include <stdlib.h> +#include <time.h> + +double timestamp(void); + +#endif // __UTILS_H__ + diff --git a/utils/utils-02.c b/utils/utils-02.c new file mode 100644 index 0000000000000000000000000000000000000000..95c887f1631b0e704fc9f46750b6ab4c89b98e5f --- /dev/null +++ b/utils/utils-02.c @@ -0,0 +1,51 @@ +// by W.Zola (2017) + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/mman.h> + +#include "utils.h" + +/* Retorna tempo em nanosegundos + + Forma de uso: + + chronometer_t *tempo; + chrono_reset( &tempo); + + chrono_start( &tempo); + <trecho de programa do qual se deseja medir tempo> + chrono_stop( &tempo); + + chrono_reportTime( &tempo, "Tempo: "); +*/ + +void chrono_reset( chronometer_t *chrono ) +{ + chrono->xtotal_ns = 0; + chrono->xn_events = 0; +} + +void chrono_start( chronometer_t *chrono ) { + clock_gettime(CLOCK_MONOTONIC_RAW, &(chrono->xadd_time1) ); +} + +void chrono_stop( chronometer_t *chrono ) { + + clock_gettime(CLOCK_MONOTONIC_RAW, &(chrono->xadd_time2) ); + + long long ns1 = chrono->xadd_time1.tv_sec*1.0e9 + chrono->xadd_time1.tv_nsec; + long long ns2 = chrono->xadd_time2.tv_sec*1.0e9 + chrono->xadd_time2.tv_nsec; + chrono->deltaT_ns = ns2 - ns1; +} + +void chrono_reportTime( chronometer_t *chrono, char *prompt ) { + printf("\n%s (ns): %llu ns\n", prompt, chrono->deltaT_ns); +} + diff --git a/utils/utils-02.h b/utils/utils-02.h new file mode 100644 index 0000000000000000000000000000000000000000..092dfec00c97b9053ec1cf2116aeb8fa79913b72 --- /dev/null +++ b/utils/utils-02.h @@ -0,0 +1,36 @@ +#ifndef __UTILS_H__ +#define __UTILS_H__ + +// by W.Zola (2017) + +#include <time.h> + +typedef struct { + + struct timespec xadd_time1, xadd_time2; + long long deltaT_ns; + +} chronometer_t; + + +/* Retorna intervlo de tempo em nanosegundos + + Forma de uso: + + chronometer_t *tempo; + chrono_reset( &tempo); + + chrono_start( &tempo); + <trecho de programa do qual se deseja medir tempo> + chrono_stop( &tempo); + + chrono_reportTime( &tempo, "Tempo: "); +*/ + +void chrono_reset( chronometer_t *chrono ); +void chrono_start( chronometer_t *chrono ); +void chrono_stop( chronometer_t *chrono ); +void chrono_reportTime( chronometer_t *chrono, chr *prompt ); + +#endif // __UTILS_H__ + diff --git a/utils/utils.c b/utils/utils.c new file mode 120000 index 0000000000000000000000000000000000000000..0879c1dde7578a82fc40778d9c266162f877b9e1 --- /dev/null +++ b/utils/utils.c @@ -0,0 +1 @@ +utils-00.c \ No newline at end of file diff --git a/utils/utils.h b/utils/utils.h new file mode 120000 index 0000000000000000000000000000000000000000..ff5fc9996db3997113887e2eafcbb7695d74a079 --- /dev/null +++ b/utils/utils.h @@ -0,0 +1 @@ +utils-00.h \ No newline at end of file