Skip to content
Snippets Groups Projects
Commit d1f0917a authored by Armando Luiz Nicolini Delgado's avatar Armando Luiz Nicolini Delgado :nerd:
Browse files

* Templates e docs para uso de 'gnuplot'

* Biblioteca 'utils' contendo:
       -> função 'timestamp()' em diferentes versões
       -> programa 'sizeof' para mostrar tamanho dos tipos em C
parent 541963b5
No related branches found
No related tags found
No related merge requests found
File added
#!/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
# Marcador "matPtrVet"
# n <METRICA 1> (sem otimização)
64 0.5
100 50.433210629261
128 25.798359943835
2000 27.337482595053
2048 18.873424079086
# Marcador "matPtrVet"
# n <METRICA 1> (com otimização)
64 0.5
100 45.433210629261
128 21.798359943835
2000 21.337482595053
2048 14.873424079086
# 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
#!/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
/home/nicolui/.html/grad/Programas/C/sizeof_01.c
\ No newline at end of file
/home/nicolui/.html/grad/Programas/C/sizeof_02.c
\ No newline at end of file
#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;
}
#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));
}
#ifndef __UTILS_H__
#define __UTILS_H__
#include <stdlib.h>
#include <sys/time.h>
double timestamp(void);
#endif // __UTILS_H__
#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));
}
#ifndef __UTILS_H__
#define __UTILS_H__
#include <stdlib.h>
#include <time.h>
double timestamp(void);
#endif // __UTILS_H__
// 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);
}
#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__
utils-00.c
\ No newline at end of file
utils-00.h
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment