# include <pslib.h>

// test psMinimizeLMChi2
int main (int argc, char **argv) {

    int i;
    psArray  *x;
    psVector  *y;
    static char *data = "test line";

    // create data array
    x = psArrayAlloc (100);
    x->n = 0;
    for (i = 0; i < 500; i++) {
      psArrayAdd (x, 100, psStringCopy (data));
    }

    // create data vector
    y = psVectorAlloc (100);
    y->n = 0;
    for (i = 0; i < y->n; i++) {
      n = y->n;
      y->data.F32[n] = 2*i;
      psVectorExtend (y, 100, 1);
      // increments n by 1, extends length if needed by 100
    }
    exit (0);
}

static psHash *timers = NULL;

bool psTimerStart (char *name) {

    psTime *start;

    if (timers == NULL) timers = psHashAlloc (16);

    start = psTimeGetTime (PS_TIME_UTC);

    psHashAdd (timers, name, start);

    return (TRUE);
}

psF64 psTimerMark (char *name) {

    psTime *start;
    psTime *mark;
    psF64   delta;

    if (timers == NULL) return (0);

    start = psHashLookup (timers, name);
    if (start == NULL) return (0);

    mark = psTimeGetTime (PS_TIME_UTC);
    delta = psTimeDelta (mark, start);
    return (delta);
}
