js/src/devtools/vprof/testVprofMT.c

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include <windows.h>
     7 #include <stdio.h>
     8 #include <time.h>
    10 #include "vprof.h"
    12 static void cProbe (void* vprofID)
    13 {
    14     if (_VAL == _IVAR1) _I64VAR1 ++;
    15     _IVAR1 = _IVAR0;
    17     if (_VAL == _IVAR0) _I64VAR0 ++;
    18     _IVAR0 = (int) _VAL;
    20     _DVAR0 = ((double)_I64VAR0) / _COUNT;
    21     _DVAR1 = ((double)_I64VAR1) / _COUNT;
    22 }
    24 //__declspec (thread) boolean cv;
    25 //#define if(c) cv = (c); _vprof (cv); if (cv)
    26 //#define if(c) cv = (c); _vprof (cv, cProbe); if (cv)
    28 #define THREADS 1
    29 #define COUNT 100000
    30 #define SLEEPTIME 0
    32 static int64_t evens = 0;
    33 static int64_t odds = 0;
    35 void sub(int val)
    36 {
    37     int i;
    38     //_vprof (1);
    39     for (i = 0; i < COUNT; i++) {
    40         //_nvprof ("Iteration", 1);
    41         //_nvprof ("Iteration", 1);
    42         _vprof (i);
    43         //_vprof (i);
    44         //_hprof(i, 3, (int64_t) 1000, (int64_t)2000, (int64_t)3000);
    45         //_hprof(i, 3, 10000, 10001, 3000000);
    46         //_nhprof("Event", i, 3, 10000, 10001, 3000000);
    47         //_nhprof("Event", i, 3, 10000, 10001, 3000000);
    48         //Sleep(SLEEPTIME);
    49         if (i % 2 == 0) {
    50             //_vprof (i);
    51             ////_hprof(i, 3, 10000, 10001, 3000000);
    52             //_nvprof ("Iteration", i);
    53             evens ++;
    54         } else {
    55             //_vprof (1);
    56             _vprof (i, cProbe);
    57             odds ++;
    58         }
    59         //_nvprof ("Iterate", 1);
    60     }
    61     //printf("sub %d done.\n", val);
    62 }
    64 HANDLE array[THREADS];
    66 static int run (void)
    67 {
    68     int i;
    70     time_t start_time = time(0);
    72     for (i = 0; i < THREADS; i++) {
    73         array[i] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sub, (LPVOID)i, 0, 0);
    74     }
    76     for (i = 0; i < THREADS; i++) {
    77         WaitForSingleObject(array[i], INFINITE);
    78     }
    80     return 0;
    81 }
    83 int main ()
    84 {
    85     DWORD start, end;
    87     start = GetTickCount ();
    88     run ();
    89     end = GetTickCount ();
    91     printf ("\nRun took %d msecs\n\n", end-start);
    92 }

mercurial