// (c) 1999-2007 Electronic Arts Inc.
#include    "spit.h"
#include    "expr.h"
#include    "stdgimex.h"

#include    "windows.h"
__forceinline __int64 GetCycle64(void) { __asm rdtsc }

main()
{
    double mary;
    const int count=1000000;

    EXPR *pExpr = EXPR_open();
    EXPR_set(pExpr, "harry", 60);
    EXPR_set(pExpr, "fred", 50);
    EXPR_set(pExpr, "hermione", 55);


    // assignment operator
    mary = EXPR_get(pExpr, "harry=51");
    printf("harry=51 %f\n",mary);

    // assignment
    mary = EXPR_get(pExpr, "a=42");
    printf("a=42 %f\n",mary);

    // test white spaces
    mary = EXPR_get(pExpr, "harry + \tfred");
    printf("harry + \\tfred %f\n",mary);

    // test seperator
    mary = EXPR_get(pExpr, "harry=fred=52,hermione");
    printf("harry=fred=52,hermione %f\n",mary);

    // test white spaces
    mary = EXPR_get(pExpr, "harry + \tfred");
    printf("harry + \\tfred %f\n",mary);


#if EXPR_VERSION>=136
    EXPR_setmode(pExpr, 1); // fast mode
#endif

#if defined(_MSC_VER)
    SetThreadPriority(0, THREAD_PRIORITY_ABOVE_NORMAL);
#endif
    __int64 t = GetCycle64();
    for (int i=0; i<count; ++i)
    {
        EXPR_set(pExpr, "harry", 60);
        EXPR_set(pExpr, "fred", 50);
        EXPR_set(pExpr, "hermione", 55);
        mary = EXPR_get(pExpr, "harry");
    }
    t = GetCycle64()-t;

    EXPR_close(pExpr);
    printf("galloccount %d\n",galloccount);
    printf("took %I64d %.2f cycles\n",t,(double)t/count);
    printf("mary %f\n",mary);
}

