Skip to content

Commit

Permalink
[1.2.2] include switch to turn on --timelog
Browse files Browse the repository at this point in the history
  • Loading branch information
michiguel committed Apr 17, 2016
1 parent 2dd9a20 commit 2ec830d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 46 deletions.
21 changes: 11 additions & 10 deletions groups.c
Expand Up @@ -762,18 +762,19 @@ groupvar_build (group_var_t *gv, player_t n_plyrs, const char **name, const stru
super_t SP;
super_t *sp = &SP;

printf ("%8.2lf | memory initialization... \n", timer_get());
timelog("memory initialization...");

if (supporting_encmem_init (encounters->n, sp, &SElnk)) {

printf ("%8.2lf | scan games... \n", timer_get());
timelog("scan games...");
scan_encounters (encounters->enc, encounters->n, gv->groupbelong, players->n, sp->SE2, &sp->N_se2, SElnk , &SElnk_n);

printf ("%8.2lf | general initialization...\n", timer_get());
timelog("general initialization...");
convert_general_init (gv, n_plyrs);

// Initiate groups from critical "super" encounters
printf ("%8.2lf | incorporate links into groups... N=%ld, Unique=%ld\n", timer_get(), (long)sp->N_se2, (long)SElnk_n);
timelog_ld("incorporate links into groups... N=", (long)sp->N_se2);
timelog_ld("incorporate links into groups... Unique=", (long)SElnk_n);

groupset_reset_finding (gv);

Expand All @@ -788,7 +789,7 @@ groupvar_build (group_var_t *gv, player_t n_plyrs, const char **name, const stru
exit(EXIT_FAILURE);
}

printf ("%8.2lf | start groups for each player with no links...\n", timer_get());
timelog("start groups for each player with no links...");

// Initiate groups for each player present in the database that did not have
// critical super encounters
Expand All @@ -797,7 +798,7 @@ groupvar_build (group_var_t *gv, player_t n_plyrs, const char **name, const stru
node_add_group (gv,i);
}

printf ("%8.2lf | add list of participants... \n", timer_get());
timelog("add list of participants...");
// for all the previous added groups, add respective list of participants
for (i = 0; i < n_plyrs; i++) {
if (node_is_occupied(gv,i)) {
Expand All @@ -808,17 +809,17 @@ groupvar_build (group_var_t *gv, player_t n_plyrs, const char **name, const stru

assert(groupset_sanity_check_nocombines(gv));

printf ("%8.2lf | group joining and simplification... \n", timer_get());
timelog("group joining and simplification...");
groupvar_simplify(gv);

printf ("%8.2lf | finish complex circuits... \n", timer_get());
timelog("finish complex circuits...");
groupvar_finish(gv);

printf ("%8.2lf | sort... \n", timer_get());
timelog("sort...");
groupvar_list_sort (gv);
groupvar_finallist_sort(gv);

printf ("%8.2lf | assign new indexes... \n", timer_get());
timelog("assign new indexes...");
groupvar_assign_newid (gv);

ret = groupvar_counter(gv) ;
Expand Down
54 changes: 28 additions & 26 deletions main.c
Expand Up @@ -129,6 +129,7 @@ struct helpline SH[] = {
{'q', "quiet", no_argument, NULL, 0, "quiet mode (no progress updates on screen)"},
{'\0', "silent", no_argument, NULL, 0, "same as --quiet"},
{'Q', "terse", no_argument, NULL, 0, "same as --quiet, but shows simulation counter"},
{'\0', "timelog", no_argument, NULL, 0, "outputs elapsed time after each step"},
{'a', "average", required_argument, "NUM", 0, "set rating for the pool average"},
{'A', "anchor", required_argument, "<player>", 0, "anchor: rating given by '-a' is fixed for <player>"},
{'V', "pool-relative",no_argument, NULL, 0, "errors relative to pool average, not to the anchor"},
Expand Down Expand Up @@ -168,7 +169,7 @@ struct helpline SH[] = {
{'i', "include", required_argument, "FILE", 0, "include only games of participants present in FILE"},
{'x', "exclude", required_argument, "FILE", 0, "names in FILE will not have their games included"},
{'\0', "no-warnings", no_argument, NULL, 0, "supress warnings of names from -x or -i that do not match names in input file"},
{'b', "column-format",required_argument, "FILE", 0, "format column output, each line being <column>,<width>,\"Header\""},
{'b', "column-format",required_argument, "FILE", 0, "format column output, each line form FILE being <column>,<width>,\"Header\""},

{0, NULL, 0, NULL, 0, NULL},

Expand Down Expand Up @@ -380,6 +381,9 @@ int main (int argc, char *argv[])
cfs_column = FALSE;
dowarning = TRUE;

// global default
TIMELOG = FALSE;

strlist_init(psl);


Expand All @@ -402,6 +406,8 @@ int main (int argc, char *argv[])
synstr = opt_arg;
} else if (!strcmp(long_options[longoidx].name, "no-warnings")) {
dowarning = FALSE;
} else if (!strcmp(long_options[longoidx].name, "timelog")) {
TIMELOG = TRUE;
} else {
fprintf (stderr, "ERROR: %d\n", op);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -707,9 +713,9 @@ int main (int argc, char *argv[])

/*==== set input ====*/

timer_reset();
printf ("%8.2lf | start \n", timer_get());
printf ("%8.2lf | input... \n", timer_get());
timer_reset();
timelog("start");
timelog("input...");

if (NULL != (pdaba = database_init_frompgn (psl, synstr, quiet_mode))) {
if (0 == pdaba->n_players || 0 == pdaba->n_games) {
Expand Down Expand Up @@ -978,8 +984,8 @@ printf ("%8.2lf | input... \n", timer_get());

summations_init(&sfe);

printf ("%8.2lf | done with input\n", timer_get());
printf ("%8.2lf | process groups if needed...\n", timer_get());
timelog("done with input");
timelog("process groups if needed...");

/*===== groups ========*/

Expand All @@ -989,19 +995,17 @@ printf ("%8.2lf | process groups if needed...\n", timer_get());
encounters_calculate (ENCOUNTERS_FULL, &Games, Players.flagged, &Encounters);

if (group_is_output || groupcheck) {

printf ("%8.2lf | processing groups... \n", timer_get());
if (NULL == (gv = GV_make (&Encounters, &Players))) {
fprintf (stderr, "not enough memory for encounters allocation\n");
exit(EXIT_FAILURE);
}
timelog("processing groups...");
if (NULL == (gv = GV_make (&Encounters, &Players))) {
fprintf (stderr, "not enough memory for encounters allocation\n");
exit(EXIT_FAILURE);
}
}

if (group_is_output) {
gamesnum_t intra;
gamesnum_t inter;
gamesnum_t intra, inter;

printf ("%8.2lf | sieve groups... \n", timer_get());
timelog("sieve groups...");
GV_sieve (gv, &Encounters, &intra, &inter);

GV_out (gv, groupf);
Expand Down Expand Up @@ -1029,7 +1033,7 @@ printf ("%8.2lf | process groups if needed...\n", timer_get());
}
}

// Not used beyond this point
// Not used anymore beyond this point
if (gv) {
GV_kill(gv);
gv = NULL;
Expand All @@ -1056,13 +1060,10 @@ printf ("%8.2lf | process groups if needed...\n", timer_get());
fprintf (stderr, "* Run switch -G to ignore warnings and force calculation *\n");
fprintf (stderr, "* (Attempting it may be very slow and may not converge) *\n");
fprintf (stderr, "*************************************************************\n");

exit(EXIT_FAILURE);
}



printf ("%8.2lf | calculate rating... \n", timer_get());
timelog("calculate rating...");

Encounters.n = calc_rating ( quiet_mode
, Forces_ML || Prior_mode
Expand Down Expand Up @@ -1105,7 +1106,7 @@ printf ("%8.2lf | calculate rating... \n", timer_get());

/* Simulation block, begin */
if (Simulate > 1) {
printf ("%8.2lf | simulation block... \n", timer_get());
timelog("simulation block...");
simul_smp
( cpus
, Simulate
Expand Down Expand Up @@ -1160,7 +1161,7 @@ printf ("%8.2lf | simulation block... \n", timer_get());

/*==== reports ====*/

printf ("%8.2lf | output reports... \n", timer_get());
timelog("output reports...");

all_report ( &Games
, &Players
Expand Down Expand Up @@ -1213,7 +1214,7 @@ printf ("%8.2lf | output reports... \n", timer_get());
}

if (head2head_str != NULL) {
printf ("%8.2lf | head to head output... \n", timer_get());
timelog("head to head output...");
head2head_output
( &Games
, &Players
Expand All @@ -1230,7 +1231,7 @@ printf ("%8.2lf | head to head output... \n", timer_get());
}

if (Elostat_output) {
printf ("%8.2lf | output in elostat format... \n", timer_get());
timelog("output in elostat format...");
cegt_output ( quiet_mode
, &Games
, &Players
Expand All @@ -1245,7 +1246,7 @@ printf ("%8.2lf | output in elostat format... \n", timer_get());
, Decimals_set? OUTDECIMALS: 0);
}

printf ("%8.2lf | release memory... \n", timer_get());
timelog("release memory...");

/*==== clean up ====*/

Expand Down Expand Up @@ -1275,7 +1276,8 @@ printf ("%8.2lf | release memory... \n", timer_get());
mythread_mutex_destroy (&Summamtx);
mythread_mutex_destroy (&Printmtx);

printf ("%8.2lf | DONE!! \n", timer_get());
timelog("DONE!!");
if (!quiet_mode) printf ("\ndone!\n");

return EXIT_SUCCESS;
}
Expand Down
39 changes: 39 additions & 0 deletions mytimer.c
@@ -1,5 +1,29 @@
/*
Ordo is program for calculating ratings of engine or chess players
Copyright 2013 Miguel A. Ballicora
This file is part of Ordo.
Ordo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ordo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ordo. If not, see <http://www.gnu.org/licenses/>.
*/

#include <time.h>
#include <stdio.h>
#include "mytimer.h"
#include "boolean.h"

bool_t TIMELOG = TRUE;

static clock_t Standard_clock = 0;

Expand All @@ -12,3 +36,18 @@ double timer_get(void)
{
return ( (double)clock()-(double)Standard_clock)/(double)CLOCKS_PER_SEC;
}

void timelog (const char *s)
{
if (TIMELOG) {printf ("%8.2lf | %s\n", timer_get(), s);}
}

void timelog_ld (const char *s, long ld)
{
if (TIMELOG) {
printf ("%8.2lf | %s%ld\n", timer_get(), s, ld);
}
}



6 changes: 6 additions & 0 deletions mytimer.h
Expand Up @@ -23,8 +23,14 @@
#define H_TIMER
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

#include "boolean.h"

extern bool_t TIMELOG;

extern void timer_reset(void);
extern double timer_get(void);
extern void timelog (const char *s);
extern void timelog_ld (const char *s, long ld);

/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
#endif
7 changes: 3 additions & 4 deletions rating.c
Expand Up @@ -766,15 +766,15 @@ calc_rating_ordo
correct_excess (n_players, flagged, excess, ratingof);
}

printf ("%8.2lf | Post-Convergence rating estimation... \n", timer_get());
timelog("Post-Convergence rating estimation...");

encounters_calculate(ENCOUNTERS_FULL, g, flagged, encount);
enc = encount->enc;
n_enc = encount->n;

calc_obtained_playedby(enc, n_enc, n_players, obtained, playedby);

printf ("%8.2lf | rate_super_players... \n", timer_get());
timelog("rate_super_players...");

rate_super_players(quiet, enc, n_enc, Performance_type, n_players, ratingof, white_adv, flagged, name, draw_rate, BETA);

Expand All @@ -784,8 +784,7 @@ printf ("%8.2lf | rate_super_players... \n", timer_get());

calc_obtained_playedby(enc, n_enc, n_players, obtained, playedby);


printf ("%8.2lf | done with rating calculation. \n", timer_get());
timelog("done with rating calculation.");

*pWhite_advantage = white_adv;
*pDraw_date = draw_rate;
Expand Down
8 changes: 4 additions & 4 deletions report.c
Expand Up @@ -846,15 +846,15 @@ all_report ( const struct GAMES *g

calc_obtained_playedby(e->enc, e->n, p->n, r->obtained, r->playedby);

printf ("%8.2lf | calculate output info... \n", timer_get());
timelog("calculate output info...");

calc_output_info( e->enc, e->n, r->ratingof_results, p->n, sdev, out_info);

for (j = 0; j < p->n; j++) {
r->sorted[j] = j;
}

printf ("%8.2lf | sort... \n", timer_get());
timelog("sort...");

my_qsort(r->ratingof_results, (size_t)p->n, r->sorted);

Expand All @@ -866,7 +866,7 @@ printf ("%8.2lf | sort... \n", timer_get());
addabsent (list_chosen, 6);
}

printf ("%8.2lf | calculation for printing... \n", timer_get());
timelog("calculation for printing...");

/* calculation for printing */
for (i = 0; i < p->n; i++) {
Expand Down Expand Up @@ -1000,7 +1000,7 @@ printf ("%8.2lf | calculation for printing... \n", timer_get());
memrel (q);
memrel (listbuff);

printf ("%8.2lf | done with all reports. \n", timer_get());
timelog("done with all reports.");

return;
}
Expand Down
2 changes: 1 addition & 1 deletion version.h
@@ -1,2 +1,2 @@
#define VERSION "1.2.1"
#define VERSION "1.2.2"

2 changes: 1 addition & 1 deletion version.txt
@@ -1 +1 @@
1.2.1
1.2.2

0 comments on commit 2ec830d

Please sign in to comment.