void DocumentLoader::startLoadingMainResource()
{
    timing().markNavigationStart();
    ASSERT(!m_mainResource);
    ASSERT(m_state == NotStarted);
    m_state = Provisional;

    if (maybeLoadEmpty())
        return;

    ASSERT(timing().navigationStart());
    ASSERT(!timing().fetchStart());
    timing().markFetchStart();

    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
        (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext));
    FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions);
    m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData);
    if (!m_mainResource) {
        m_request = ResourceRequest(blankURL());
        maybeLoadEmpty();
        return;
    }
    // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
    // Even when using a cached resource, we may make some modification to the request, e.g. adding the referer header.
    m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest();
    m_mainResource->addClient(this);
}
Beispiel #2
0
void tess_kdtree_exchange(diy::Master& master,
                          const diy::Assigner& assigner,
                          double* times,
                          bool wrap,
                          bool sampling)
{
    timing(times, EXCH_TIME, -1, master.communicator());

    diy::Master kdtree_master(master.communicator(),  master.threads(), -1);
    master.foreach([&](DBlock* b, const diy::Master::ProxyWithLink& cp)
                   { populate_kdtree_block(b, cp, kdtree_master, wrap); });

    int bins = 1024;      // histogram bins; TODO: make a function argument
    diy::ContinuousBounds domain = master.block<DBlock>(master.loaded_block())->data_bounds;
    if (sampling)
        diy::kdtree_sampling(kdtree_master, assigner, 3, domain, &KDTreeBlock::points, bins, wrap);
    else
        diy::kdtree(kdtree_master, assigner, 3, domain, &KDTreeBlock::points, bins, wrap);

    kdtree_master.foreach([&](KDTreeBlock* b, const diy::Master::ProxyWithLink& cp)
                          { extract_kdtree_block(b, cp, master); });
    master.set_expected(kdtree_master.expected());

    timing(times, -1, EXCH_TIME, master.communicator());
}
Beispiel #3
0
double Benchmark::run (unsigned long long duration)
{
    // determine how many times to run a test
    unsigned repetitions = calibrate (&Benchmark::loaded_iter, duration);
    if (repetitions == 0)
        return 0;

    // measure the loaded time
    long long elapsed_loaded = timing (repetitions, &Benchmark::loaded_iter);
    if (elapsed_loaded < 0)
        return 0;

    // measure the dummy time
    long long elapsed_dummy = timing (repetitions, &Benchmark::dummy_iter);
    if (elapsed_dummy < 0)
        return 0;

    // subtract dummy from loaded time
    long long elapsed;
    if (elapsed_dummy != 0 && elapsed_dummy < elapsed_loaded)
        elapsed = elapsed_loaded - elapsed_dummy;
    else
        elapsed = elapsed_loaded;

    // elapsed is in microsecs, scale the speed
    return ((double) repetitions) * USECS_IN_SEC / elapsed;
}
void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
    ASSERT_UNUSED(resource, resource == m_mainResource);
    ASSERT(!redirectResponse.isNull());
    m_request = request;

    // If the redirecting url is not allowed to display content from the target origin,
    // then block the redirect.
    const KURL& requestURL = m_request.url();
    RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
    if (!redirectingOrigin->canDisplay(requestURL)) {
        FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
        m_fetcher->stopFetching();
        return;
    }
    if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteData(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurrentTab, replacesCurrentHistoryItem(), isClientRedirect())) {
        m_fetcher->stopFetching();
        return;
    }

    ASSERT(timing().fetchStart());
    timing().addRedirect(redirectResponse.url(), requestURL);
    appendRedirect(requestURL);
    frameLoader()->receivedMainResourceRedirect(requestURL);
}
Beispiel #5
0
struct copy_graph_node * permute_copies(
    struct copy_graph_node **copy_graph_head, struct add_list * add_list)
{
    int count;
    struct copy_graph_node * topo_list_head;
    struct copy_graph_node ** node_array;

    if(do_stats) {
        timing(TIMING_START);
    }
    node_array = build_edges(*copy_graph_head,&count);
    if(do_stats) {
        rprintf(FINFO, "Build graph: %s\n", timing(TIMING_END));
    }
    if(do_stats) {
        timing(TIMING_START);
    }
    topo_list_head = topo_sort(node_array,count, add_list);
    if(do_stats) {
        rprintf(FINFO, "Topological sort: %s\n", timing(TIMING_END));
    }
    update_extra_memory(-(count * sizeof(struct copy_graph_node * )));
    if(do_stats) {
        rprintf(FINFO, "Extra memory: %d Extra bytes sent: %d\n",
                max_extra_memory,extra_bytes);
        rprintf(FINFO, "Broken copies without delta comp: %d\n",
                broken_copies);
        rprintf(FINFO, "Cycles broken: %d Bytes trimmed: %d\n",
                cycles_broken, bytes_trimmed);
    }

    free(node_array);
    return topo_list_head;
}
Beispiel #6
0
int main() {
    double t1, t2, cpu_t, pi;
    timing(&t1, &cpu_t);
    pi = approx_pi();
    printf("Pi=%lf, sin(Pi)=%lf\n", pi, sin(pi));
    timing(&t2, &cpu_t);
    printf("Time spent: %lf, ", t2 - t1);
    printf("MFlops/s = %lf\n", (4 * (N / 1000000)) / (t2 - t1));
    return 0;
}
Beispiel #7
0
void DocumentLoader::startLoadingMainResource()
{
    m_mainDocumentError = ResourceError();
    timing()->markNavigationStart();
    ASSERT(!m_mainResource);
    ASSERT(!m_loadingMainResource);
    m_loadingMainResource = true;

    if (maybeLoadEmpty())
        return;

    ASSERT(timing()->navigationStart());
    ASSERT(!timing()->fetchStart());
    timing()->markFetchStart();
    willSendRequest(m_request, ResourceResponse());

    // willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest.
    if (!m_frame || m_request.isNull())
        return;

    m_applicationCacheHost->willStartLoadingMainResource(m_request);
    prepareSubframeArchiveLoadIfNeeded();

    if (m_substituteData.isValid()) {
        m_identifierForLoadWithoutResourceLoader = createUniqueIdentifier();
        frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse());
        handleSubstituteDataLoadSoon();
        return;
    }

    ResourceRequest request(m_request);
    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
        (SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck, CheckContentSecurityPolicy, UseDefaultOriginRestrictionsForType));
    CachedResourceRequest cachedResourceRequest(request, cachedResourceRequestInitiators().document, mainResourceLoadOptions);
    m_mainResource = m_cachedResourceLoader->requestMainResource(cachedResourceRequest);
    if (!m_mainResource) {
        setRequest(ResourceRequest());
        // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
        // is now in a state where starting an empty load will be inconsistent. Replace it with
        // a new ApplicationCacheHost.
        m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this));
        maybeLoadEmpty();
        return;
    }
    m_mainResource->addClient(this);

    // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
    if (mainResourceLoader())
        request = mainResourceLoader()->originalRequest();
    // If there was a fragment identifier on m_request, the cache will have stripped it. m_request should include
    // the fragment identifier, so add that back in.
    if (equalIgnoringFragmentIdentifier(m_request.url(), request.url()))
        request.setURL(m_request.url());
    setRequest(request);
}
Beispiel #8
0
void DocumentLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
{
    // Note that there are no asserts here as there are for the other callbacks. This is due to the
    // fact that this "callback" is sent when starting every load, and the state of callback
    // deferrals plays less of a part in this function in preventing the bad behavior deferring 
    // callbacks is meant to prevent.
    ASSERT(!newRequest.isNull());

    if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url())) {
        cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
        return;
    }

    ASSERT(timing()->fetchStart());
    if (!redirectResponse.isNull()) {
        // If the redirecting url is not allowed to display content from the target origin,
        // then block the redirect.
        RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
        if (!redirectingOrigin->canDisplay(newRequest.url())) {
            FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string());
            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
            return;
        }
        timing()->addRedirect(redirectResponse.url(), newRequest.url());
    }

    // Update cookie policy base URL as URL changes, except for subframes, which use the
    // URL of the main frame which doesn't change when we redirect.
    if (frameLoader()->isLoadingMainFrame())
        newRequest.setFirstPartyForCookies(newRequest.url());

    // If we're fielding a redirect in response to a POST, force a load from origin, since
    // this is a common site technique to return to a page viewing some data that the POST
    // just modified.
    // Also, POST requests always load from origin, but this does not affect subresources.
    if (newRequest.cachePolicy() == UseProtocolCachePolicy && isPostOrRedirectAfterPost(newRequest, redirectResponse))
        newRequest.setCachePolicy(ReloadIgnoringCacheData);

    Frame* top = m_frame->tree()->top();
    if (top) {
        if (!top->loader()->mixedContentChecker()->canDisplayInsecureContent(top->document()->securityOrigin(), newRequest.url())) {
            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
            return;
        }
    }

    setRequest(newRequest);

    if (redirectResponse.isNull())
        return;

    frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();
    if (!shouldContinueForNavigationPolicy(newRequest))
        stopLoadingForPolicyChange();
}
Beispiel #9
0
int main(int argc, char** argv) {

  double wct_start,wct_end,cput_start,cput_end,runtime,r;
  int iter,size,i,j,k,n;
  double *f1, *f2;

  iter=1000;
  double mintime = 4.0;

  if (argc != 2 && argc != 3) {
    printf("Usage: %s <size> [mintime]\n",argv[0]);
    exit(1);
  }
  if (argc == 3) {
    mintime = atof(argv[2]);
  }

  size = atoi(argv[1]);
  f1 = malloc((size_t)size*sizeof(double));
  f2 = malloc((size_t)size*sizeof(double));

#pragma omp parallel for schedule(static)
  for (i = 0; i < size; i++) {
    f1[i] = sin( (double) i * i);
    f2[i] = cos( (double) 2*i);
  } 

  // time measurement
  timing(&wct_start, &cput_start);

  double sum = 0.0;

  while (1) {
    timing(&wct_start, &cput_start);
    for (j = 0; j < iter; j++) {
#pragma omp parallel for reduction(+:sum) schedule(static)
      for (i = 0; i < size; i++) {
        sum += f1[i]*f1[i];
      }
    }
    timing(&wct_end, &cput_end);
    // making sure mintime was spent, otherwise restart with 2*iter
    if (wct_end - wct_start > mintime) {
      break;
    }
    iter = iter * 2;
  }

  runtime = wct_end - wct_start;

  printf("size:\t%d\ttime/iter:\t%lf\tGFLOP/s:\t%lf\n", size, runtime/iter, ((double)iter) * size * 1e-9 / runtime);
  
  return 0;
}
Beispiel #10
0
int
main(int argc, char *argv[])
{
	LassoServer *sp_server, *idp_server;
	LassoLogin *sp_login, *idp_login;
	int n;

	lasso_init();

	sp_server = lasso_server_new(
			SP_METADATA,
			SP_PKEY,
			NULL, /* Secret key to unlock private key */
			NULL);
	lasso_server_add_provider(
			sp_server,
			LASSO_PROVIDER_ROLE_IDP,
			IDP_METADATA,
			IDP_PKEY,
			NULL);
	idp_server = lasso_server_new(
			IDP_METADATA,
			IDP_PKEY,
			NULL, /* Secret key to unlock private key */
			NULL);
	lasso_server_add_provider(
			idp_server,
			LASSO_PROVIDER_ROLE_SP,
			SP_METADATA,
			SP_PKEY,
			NULL);

	n = 100;
	if (argc == 2) {
		n = atoi(argv[1]);
	}

	sp_login = lasso_login_new(sp_server);
	idp_login = lasso_login_new(idp_server);

	timing(n, "Generating %d AuthnRequest...\n", create_authn_request, sp_login, idp_login);
#if 0
	printf("%s\n", lasso_node_export_to_xml(sp_login->parent.request));
#endif
	timing(n, "Processing %d AuthnRequest...\n", process_authn_request, sp_login, idp_login);
	timing(n, "Generating %d AuthnResponse...\n", create_authn_response, sp_login, idp_login);
#if 0
	printf("%s\n", lasso_node_export_to_xml(idp_login->parent.response));
#endif
	timing(n, "Processing %d AuthnResponse...\n", process_authn_response, sp_login, idp_login);

	return 0;
}
Beispiel #11
0
void DocumentLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
{
    // Note that there are no asserts here as there are for the other callbacks. This is due to the
    // fact that this "callback" is sent when starting every load, and the state of callback
    // deferrals plays less of a part in this function in preventing the bad behavior deferring
    // callbacks is meant to prevent.
    ASSERT(!newRequest.isNull());
    if (isFormSubmission(m_triggeringAction.type()) && !m_frame->document()->contentSecurityPolicy()->allowFormAction(newRequest.url())) {
        cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
        return;
    }

    ASSERT(timing()->fetchStart());
    if (!redirectResponse.isNull()) {
        // If the redirecting url is not allowed to display content from the target origin,
        // then block the redirect.
        RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
        if (!redirectingOrigin->canDisplay(newRequest.url())) {
            FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string());
            cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
            return;
        }
        timing()->addRedirect(redirectResponse.url(), newRequest.url());
    }

    // If we're fielding a redirect in response to a POST, force a load from origin, since
    // this is a common site technique to return to a page viewing some data that the POST
    // just modified.
    if (newRequest.cachePolicy() == UseProtocolCachePolicy && isRedirectAfterPost(newRequest, redirectResponse))
        newRequest.setCachePolicy(ReloadBypassingCache);

    // If this is a sub-frame, check for mixed content blocking against the top frame.
    if (m_frame->tree().parent()) {
        // FIXME: This does not yet work with out-of-process iframes.
        Frame* top = m_frame->tree().top();
        if (top->isLocalFrame() && !toLocalFrame(top)->loader().mixedContentChecker()->canRunInsecureContent(toLocalFrame(top)->document()->securityOrigin(), newRequest.url())) {
            cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
            return;
        }
    }

    m_request = newRequest;

    if (redirectResponse.isNull())
        return;

    appendRedirect(newRequest.url());
    frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();
    if (!shouldContinueForNavigationPolicy(newRequest))
        cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
}
Beispiel #12
0
int main(int argc, char* argv){
  uint64_t seed;
  Compl z, c, tmp;
  int i, j;
  int N1, N0;
  double etime0, etime1, cptime;
  double A; 
  double r;
  int n;
  // boundary
  lowerLeft.real = -2.0;
  lowerLeft.imag = 0;
  upperRight.real = 0.5;
  upperRight.imag = 1.125;
  omp_set_dynamic(0);
  #pragma omp parallel
  dsrand(12345);

  N1 = N0 = 0;
  timing(&etime0, &cptime);

  #pragma omp parallel firstprivate(j, n, c, z, tmp, stride) \
                      shared(i, N0, N1, lowerLeft, upperRight, threshold, MAX_ITERATE)
  #pragma omp for schedule(static, 10) collapse(2)
  for(i = 0; i < (int)((upperRight.real - lowerLeft.real) / stride); i++){
    for(j = 0; j < (int)((upperRight.imag - lowerLeft.imag) / stride); j++){
      if(i == 0 && j == 0 && omp_get_thread_num() == 0) printf("Threads: %d\n", omp_get_num_threads());
      c.real = lowerLeft.real + (drand() + i) * stride;
      c.imag = lowerLeft.imag + (drand() + j) * stride;
      z = c;
      for(n = 0; n < MAX_ITERATE; n++){
        multiply(&z, &c, &tmp);
        z = tmp;
        if(lengthsq(&z) > threshold * threshold){
            break;
        }        
      }
      if(n == MAX_ITERATE){
        #pragma omp critical(N1)
        N1++;
      }else{
        #pragma omp critical(N0)
        N0++;
      }
    }
  }
  timing(&etime1, &cptime);
  A = 2.0 * N1 / (N0 + N1) * (upperRight.real - lowerLeft.real) * (upperRight.imag - lowerLeft.imag);
  printf("area is %f, time elapsed is %f, total cell: %d\n", A, etime1 - etime0, N1 + N0);
}
Beispiel #13
0
void DocumentLoader::startLoadingMainResource()
{
    RefPtr<DocumentLoader> protect(this);
    m_mainDocumentError = ResourceError();
    timing()->markNavigationStart();
    ASSERT(!m_mainResource);
    ASSERT(!m_loadingMainResource);
    m_loadingMainResource = true;

    if (maybeLoadEmpty())
        return;

    ASSERT(timing()->navigationStart());
    ASSERT(!timing()->fetchStart());
    timing()->markFetchStart();
    willSendRequest(m_request, ResourceResponse());

    // willSendRequest() may lead to our LocalFrame being detached or cancelling the load via nulling the ResourceRequest.
    if (!m_frame || m_request.isNull())
        return;

    m_applicationCacheHost->willStartLoadingMainResource(m_request);
    prepareSubframeArchiveLoadIfNeeded();

    ResourceRequest request(m_request);
    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
        (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext));
    FetchRequest cachedResourceRequest(request, FetchInitiatorTypeNames::document, mainResourceLoadOptions);
    m_mainResource = m_fetcher->fetchMainResource(cachedResourceRequest, m_substituteData);
    if (!m_mainResource) {
        m_request = ResourceRequest();
        // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
        // is now in a state where starting an empty load will be inconsistent. Replace it with
        // a new ApplicationCacheHost.
        m_applicationCacheHost = ApplicationCacheHost::create(this);
        maybeLoadEmpty();
        return;
    }
    m_mainResource->addClient(this);

    // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
    if (mainResourceLoader())
        request = mainResourceLoader()->originalRequest();
    // If there was a fragment identifier on m_request, the cache will have stripped it. m_request should include
    // the fragment identifier, so add that back in.
    if (equalIgnoringFragmentIdentifier(m_request.url(), request.url()))
        request.setURL(m_request.url());
    m_request = request;
}
Beispiel #14
0
void WebDataSourceImpl::updateNavigation(
    double redirectStartTime,
    double redirectEndTime,
    double fetchStartTime,
    const WebVector<WebURL>& redirectChain) {
  // Updates the redirection timing if there is at least one redirection
  // (between two URLs).
  if (redirectChain.size() >= 2) {
    for (size_t i = 0; i + 1 < redirectChain.size(); ++i)
      didRedirect(redirectChain[i], redirectChain[i + 1]);
    timing().setRedirectStart(redirectStartTime);
    timing().setRedirectEnd(redirectEndTime);
  }
  timing().setFetchStart(fetchStartTime);
}
Beispiel #15
0
int main()
{
   volatile int* loadvars = malloc(10000*sizeof(int));
   volatile int* loadvare = loadvars+9999;
   //uint64_t t_res = timing_res();
   unsigned long beg = 0, end = 0, sum = 0, ref = 0;
   for(int i=0;i<REPEAT;i++){
      uint64_t t_err = timing_err();
      beg = timing();
      ref += inst_template("loadwithrand",loadvars,loadvare);
      end = timing(); 
      sum += end-beg-t_err;
   }
   sum /= REPEAT;
    printf("loadwithrand Time:%lu, ref:10000,no use:%lu\n", sum,ref);
}
Beispiel #16
0
void eventLoop()
{
	while (list_size[LIST_EVENT] != 0) {

		/* Determine the next event. */
		timing();

		switch (next_event_type) {

		case EVENT_BLOOD_ARRIVAL:
			bloodCamp();
			break;
		case EVENT_BLOOD_DONATION:
			bloodDonation();
			break;
		case EVENT_BLOOD_DEMAND:
			bloodDemand();
			break;
		case EVENT_BLOOD_EXPIRATION:
			bloodExpiration();
			break;
		case EVENT_END_SIMULATION:
			return;
			break;
		}
	}
}
Beispiel #17
0
void DocumentLoader::startLoadingMainResource()
{
    m_mainDocumentError = ResourceError();
    timing()->markNavigationStart();
    ASSERT(!m_mainResourceLoader);

    if (maybeLoadEmpty())
        return;

    m_mainResourceLoader = MainResourceLoader::create(this);

    // FIXME: Is there any way the extra fields could have not been added by now?
    // If not, it would be great to remove this line of code.
    // Note that currently, some requests may have incorrect extra fields even if this function has been called,
    // because we pass a wrong loadType (see FIXME in addExtraFieldsToMainResourceRequest()).
    frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
    m_mainResourceLoader->load(m_request, m_substituteData);

    if (m_request.isNull()) {
        m_mainResourceLoader = 0;
        // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
        // is now in a state where starting an empty load will be inconsistent. Replace it with
        // a new ApplicationCacheHost.
        m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this));
        maybeLoadEmpty();
    }
}
Beispiel #18
0
bool DocumentLoader::redirectReceived(
    Resource* resource,
    const ResourceRequest& request,
    const ResourceResponse& redirectResponse) {
  DCHECK_EQ(resource, m_mainResource);
  DCHECK(!redirectResponse.isNull());
  m_request = request;

  // If the redirecting url is not allowed to display content from the target
  // origin, then block the redirect.
  const KURL& requestURL = m_request.url();
  RefPtr<SecurityOrigin> redirectingOrigin =
      SecurityOrigin::create(redirectResponse.url());
  if (!redirectingOrigin->canDisplay(requestURL)) {
    FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString());
    m_fetcher->stopFetching();
    return false;
  }
  if (!frameLoader()->shouldContinueForNavigationPolicy(
          m_request, SubstituteData(), this, CheckContentSecurityPolicy,
          m_navigationType, NavigationPolicyCurrentTab,
          replacesCurrentHistoryItem(), isClientRedirect(), nullptr)) {
    m_fetcher->stopFetching();
    return false;
  }

  DCHECK(timing().fetchStart());
  appendRedirect(requestURL);
  didRedirect(redirectResponse.url(), requestURL);
  frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();

  return true;
}
Beispiel #19
0
void DocumentLoader::finishedLoading(double finishTime) {
  DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() ||
         !m_frame->page()->defersLoading() ||
         InspectorInstrumentation::isDebuggerPaused(m_frame));

  double responseEndTime = finishTime;
  if (!responseEndTime)
    responseEndTime = m_timeOfLastDataReceived;
  if (!responseEndTime)
    responseEndTime = monotonicallyIncreasingTime();
  timing().setResponseEnd(responseEndTime);

  commitIfReady();
  if (!frameLoader())
    return;

  if (!maybeCreateArchive()) {
    // If this is an empty document, it will not have actually been created yet.
    // Commit dummy data so that DocumentWriter::begin() gets called and creates
    // the Document.
    if (!m_writer)
      commitData(0, 0);
  }

  if (!m_frame)
    return;

  m_applicationCacheHost->finishedLoadingMainResource();
  endWriting();
  if (m_state < MainResourceDone)
    m_state = MainResourceDone;
  clearMainResourceHandle();
}
Beispiel #20
0
void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) {
  timing().addRedirect(oldURL, newURL);

  // If a redirection happens during a back/forward navigation, don't restore
  // any state from the old HistoryItem. There is a provisional history item for
  // back/forward navigation only. In the other case, clearing it is a no-op.
  DCHECK(frameLoader());
  frameLoader()->clearProvisionalHistoryItem();
}
Beispiel #21
0
Datei: depth.c Projekt: hvds/seq
void report_progress(ulong depth) {
    ulong i;
    ulong lim = (max_depth > 20) ? 20 : max_depth;
    gmp_printf("%Qd: tried %lu values (%.2fs) ", r, count, timing());
    for (i = 0; i < lim; ++i) {
        frame_t *f = &stack[i];
        printf("%lu%s", f->actual, (i < lim - 1) ? " ": "\n");
    }
}
Beispiel #22
0
void DocumentLoader::startLoadingMainResource() {
  timing().markNavigationStart();
  DCHECK(!m_mainResource);
  DCHECK_EQ(m_state, NotStarted);
  m_state = Provisional;

  if (maybeLoadEmpty())
    return;

  DCHECK(timing().navigationStart());

  // PlzNavigate:
  // The fetch has already started in the browser. Don't mark it again.
  if (!m_frame->settings()->browserSideNavigationEnabled()) {
    DCHECK(!timing().fetchStart());
    timing().markFetchStart();
  }

  DEFINE_STATIC_LOCAL(
      ResourceLoaderOptions, mainResourceLoadOptions,
      (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials,
       CheckContentSecurityPolicy, DocumentContext));
  FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document,
                            mainResourceLoadOptions);
  m_mainResource =
      RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData);

  // PlzNavigate:
  // The final access checks are still performed here, potentially rejecting
  // the "provisional" load, but the browser side already expects the renderer
  // to be able to unconditionally commit.
  if (!m_mainResource || (m_frame->settings()->browserSideNavigationEnabled() &&
                          m_mainResource->errorOccurred())) {
    m_request = ResourceRequest(blankURL());
    maybeLoadEmpty();
    return;
  }
  // A bunch of headers are set when the underlying resource load begins, and
  // m_request needs to include those. Even when using a cached resource, we may
  // make some modification to the request, e.g. adding the referer header.
  m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest()
                                          : fetchRequest.resourceRequest();
  m_mainResource->addClient(this);
}
Beispiel #23
0
 int App::run()
 {
     try{init(); m_running = GL_TRUE;}
     catch(std::exception &e){LOG_ERROR<<e.what();}
     double timeStamp = 0.0;
     
     // Main loop
     while( m_running )
     {            
         // update application time
         timeStamp = getApplicationTime();
         
         // poll io_service if no seperate worker-threads exist
         if(!m_main_queue.get_num_threads()) m_main_queue.io_service().poll();
         
         // poll input events
         pollEvents();
         
         // time elapsed since last frame
         double time_delta = timeStamp - m_lastTimeStamp;
         
         // call update callback
         update(time_delta);
         
         m_lastTimeStamp = timeStamp;
         
         if(needs_redraw())
         {
             // call draw callback
             draw_internal();
             
             // Swap front and back rendering buffers
             swapBuffers();
         }
         
         // perform fps-timing
         timing(timeStamp);
         
         // Check if ESC key was pressed or window was closed or whatever
         m_running = checkRunning();
         
         // fps managment
         float current_fps = 1.f / time_delta;
         
         if(current_fps > m_max_fps)
         {
             double sleep_secs = std::max(0.0, (1.0 / m_max_fps - time_delta));
             this_thread::sleep_for(duration_t(sleep_secs));
         }
     }
     
     // manage tearDown, save stuff etc.
     tearDown();
     
     return EXIT_SUCCESS;
 }
Beispiel #24
0
int
main(int argc, char **argv)
{
  int len_base = 5;
  int len_rand = 1;
  int ndl_max = 1024;
  if (argc > 2) {
    len_base = atoi(argv[2]);
  }
  if (argc > 3) {
    len_rand = atoi(argv[3]);
  }
  if (argc > 4) {
    ndl_max = atoi(argv[4]);
  }
  if (argc > 1 && strcmp(argv[1], "bin") == 0) {
    timing(100, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else if (argc > 1 && strcmp(argv[1], "bin0") == 0) {
    timing(100, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else if (argc > 1 && strcmp(argv[1], "bin1") == 0) {
    timing(101, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else if (argc > 1 && strcmp(argv[1], "bin2") == 0) {
    timing(102, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else if (argc > 1 && strcmp(argv[1], "karp") == 0) {
    if (len_rand > 1) {
      std::cerr << "LEN_RAND must be 1 for karp" << std::endl;
    } else if (len_base != 5) {
      std::cerr << "LEN_BASE must be 5 for karp" << std::endl;
    } else {
      timing(200, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
    }
  } else if (argc > 1 && strncmp(argv[1], "karp", 4) == 0) {
    if (len_rand > 1) {
      std::cerr << "LEN_RAND must be 1 for karp??" << std::endl;
    } else if (len_base != 5) {
      std::cerr << "LEN_BASE must be 5 for karp??" << std::endl;
    } else {
      int num_threads = atoi(argv[1] + 4);
      timing(200 + num_threads, 10*1000, 10*1000, false, ndl_max, len_base,
	len_rand);
    }
  } else if (argc > 1 && strcmp(argv[1], "horspool") == 0) {
    timing(1, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else if (argc > 1 && strcmp(argv[1], "naive") == 0) {
    timing(0, 10*1000, 10*1000, false, ndl_max, len_base, len_rand);
  } else {
    std::cerr << "Usage: " << argv[0] <<
      " [ bin | bin0 | bin1 | bin2 | karp | karpmt | horspool | naive ] "
	"[LEN_BASE] [LEN_RAND] [NEEDLE_MAX]"
      << std::endl;
  }
  return 0;
}
Beispiel #25
0
static int wcreceive(int argc, char **argp)
{
	int c;

	if (Batch || argc == 0) {
		Crcflg = 1;
		if (!Quiet)
			fprintf(stderr, rbmsg, Progname, "sz");
		if ((c = tryz())) {
			if (c == ZCOMPL)
				return OK;
			if (c == ERROR)
				goto fubar;
			c = rzfiles();
			if (c)
				goto fubar;
		} else {
			for (;;) {
				if (wcrxpn(secbuf) == ERROR)
					goto fubar;
				if (secbuf[0] == 0)
					return OK;
				if (procheader(secbuf) == ERROR)
					goto fubar;
				if (wcrx() == ERROR)
					goto fubar;
			}
		}
	} else {
		Bytesleft = DEFBYTL;
		Filemode = 0;
		Modtime = 0L;

		procheader("");
		strcpy(Pathname, *argp);
		checkpath(Pathname);
		fprintf(stderr, "\n%s: ready to receive %s\r\n", Progname,
			Pathname);
		if ((fout = fopen(Pathname, "w")) == NULL)
			return ERROR;
		if (wcrx() == ERROR)
			goto fubar;
		timing(1);
	}
	return OK;
      fubar:
	canit();
	if (Topipe && fout) {
		pclose(fout);
		return ERROR;
	}
	if (fout)
		closeit();
	return ERROR;
}
void DocumentLoader::startLoadingMainResource()
{
    m_mainDocumentError = ResourceError();
    timing()->markNavigationStart(m_frame);
    ASSERT(!m_mainResourceLoader);
    m_mainResourceLoader = MainResourceLoader::create(m_frame);

    // FIXME: Is there any way the extra fields could have not been added by now?
    // If not, it would be great to remove this line of code.
    frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
    m_mainResourceLoader->load(m_request, m_substituteData);
}
Beispiel #27
0
void *power_thread(void *arg)
{
    pthread_mutex_lock(&m_lock);
    printf("Power Thread running\n");
    /*等待满足条件,期间互斥量仍然可用*/
    while (1)
    {
        pthread_cond_wait(&poweroff_ready, &m_lock);
        timing();
    }
    pthread_mutex_unlock(&m_lock);
    //pthread_exit(NULL);
}
Beispiel #28
0
int main()  /* Main function. */
{
    /* Open input and output files. */
    infile  = fopen("mm1.in",  "r");
    outfile = fopen("mm1.out", "w");

    /* Specify the number of events for the timing function. */
    num_events = 2;

    /* Read input parameters. */
    fscanf(infile, "%f %f %d", &mean_interarrival, &mean_service,
           &num_delays_required);

    /* Write report heading and input parameters. */
    fprintf(outfile, "Single-server queueing system\n\n");
    fprintf(outfile, "Mean interarrival time%11.3f minutes\n\n",mean_interarrival);
    fprintf(outfile, "Mean service time%16.3f minutes\n\n", mean_service);
    fprintf(outfile, "Number of customers%14d\n\n", num_delays_required);

    /* Initialize the simulation. */
    initialize();

    /* Run the simulation while more delays are still needed. */
    while (num_custs_delayed < num_delays_required) {
        /* Determine the next event. */
        timing();

        /* Update time-average statistical accumulators. */
        update_time_avg_stats();

        /* Invoke the appropriate event function. */
        switch (next_event_type) {
            case 1:
                arrive();
                break;
            case 2:
                depart();
                break;
        }
    }

    /* Invoke the report generator and end the simulation. */
    report();

    fclose(infile);
    fclose(outfile);

    return 0;
}
Beispiel #29
0
void DocumentLoader::finishedLoading(double finishTime)
{
    ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame));

    RefPtr<DocumentLoader> protect(this);

    if (m_identifierForLoadWithoutResourceLoader) {
        frameLoader()->notifier()->dispatchDidFinishLoading(this, m_identifierForLoadWithoutResourceLoader, finishTime);
        m_identifierForLoadWithoutResourceLoader = 0;
    }

    double responseEndTime = finishTime;
    if (!responseEndTime)
        responseEndTime = m_timeOfLastDataReceived;
    if (!responseEndTime)
        responseEndTime = monotonicallyIncreasingTime();
    timing()->setResponseEnd(responseEndTime);

    commitIfReady();
    if (!frameLoader())
        return;

    if (!maybeCreateArchive()) {
        // If this is an empty document, it will not have actually been created yet. Commit dummy data so that
        // DocumentWriter::begin() gets called and creates the Document.
        if (!m_gotFirstByte)
            commitData(0, 0);
        frameLoader()->client()->finishedLoading(this);
    }

    m_writer.end();
    if (!m_mainDocumentError.isNull())
        return;
    clearMainResourceLoader();
    if (!frameLoader()->stateMachine()->creatingInitialEmptyDocument())
        frameLoader()->checkLoadComplete();

    // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
    // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
    if (m_frame) {
        if (m_mainResource && m_frame->document()->hasManifest())
            memoryCache()->remove(m_mainResource.get());
    }
    m_applicationCacheHost->finishedLoadingMainResource();
    clearMainResourceHandle();
}
int main(int argc, char * argv[]) {
	if (argc != 3) {
		printf("Please enter 2 arguments!\n");
		printf("The first argument is the length of array to test Insertion Sort\n");
		printf("The second argument is that of array to test the other 6 sorts\n");
		return 0;
	}
	int lengthInsertionSort = atoi(*(argv + 1));
	int lengthOtherSorts = atoi(*(argv + 2));
	
	// init function pointer	
	void (*fp[NUMBER_OF_SORTS])(int *, int);
	*fp = insertion_sort;
	*(fp + 1) = merge_sort;
	*(fp + 2) = heap_sort;
	*(fp + 3) = quick_sort_hoare;
	*(fp + 4) = quick_sort_median;
	*(fp + 5) = quick_sort_random;
	
	char * functionNames[NUMBER_OF_SORTS] = {"insertion_sort", "merge_sort",
								"heap_sort", "quick_sort_hoare",
								"quick_sort_median", "quick_sort_random"};
	
	for (int i = 0; i < NUMBER_OF_SORTS; i++) {
		unsigned int totalTime = 0;		

		int length = 0;
		if (i == 0) 	length = lengthInsertionSort;
		else 			length = lengthOtherSorts;
		
		for (int j = 0; j < 3; j++) {
			// set different seeds for different tests
			srand((j / (i + 1)) * time(NULL)); 
			
			// generate array with length size.
			// each integer is 16-bits size
			int *arr = gen_rand_int_array(length, BIT_SIZE);
			
			totalTime += timing(arr, length, *(fp + i));
			if (!is_sorted(arr, 0, length - 1)) printf("Sorting fails\n");
			free(arr);
		}
		printf("%s,\tsize: %i,\ttime: %i\n",
				*(functionNames + i), length, totalTime / 3);
	}
}