int main() {
    double begin, end;
    char *a = (char *)malloc(SIZE * GB * sizeof(char));
    char c;

    memset(a, 0xFF, SIZE * GB); //flush
    begin = monotonic_time();
    // memset(a, 0x01, SIZE * GB);
    for (long i = 0; i < SIZE * GB; i+= 64) {
        a[i] = 0x00;    
    }
    end = monotonic_time();
    printf("Memory Bandwidth for writing: %.2lf (array size = %d GB)\n", 1.0*SIZE/(end-begin), SIZE);

    memset(a, 0xFF, SIZE * GB); //flush
    begin = monotonic_time();
    for (long i = 0; i < SIZE * GB; i+= 64) {
        c = a[i];
    }
    end = monotonic_time();    
    printf("Memory Bandwidth for reading: %.2lf (array size = %d GB)\n", 1.0*SIZE/(end-begin), SIZE);

    free(a);
    return 0;
}
Esempio n. 2
0
void * Query_Cache::purgeHash_thread(void *) {
	unsigned int i;
	while (shutdown==0) {
		usleep(purge_loop_time);
		unsigned long long t=monotonic_time()/1000;
		QCnow_ms=t;

		if (current_used_memory_pct() < purge_threshold_pct_min ) continue;
		for (i=0; i<SHARED_QUERY_CACHE_HASH_TABLES; i++) {
			KVs[i].purge_some(QCnow_ms);
		}
	}
	return NULL;
};
Esempio n. 3
0
Query_Cache::Query_Cache() {
#ifdef DEBUG
	if (glovars.has_debug==false) {
#else
	if (glovars.has_debug==true) {
#endif /* DEBUG */
		perror("Incompatible debagging version");
		exit(EXIT_FAILURE);
	}
	QCnow_ms=monotonic_time()/1000;
	size=SHARED_QUERY_CACHE_HASH_TABLES;
	shutdown=0;
	purge_loop_time=DEFAULT_purge_loop_time;
	purge_total_time=DEFAULT_purge_total_time;
	purge_threshold_pct_min=DEFAULT_purge_threshold_pct_min;
	purge_threshold_pct_max=DEFAULT_purge_threshold_pct_max;
	max_memory_size=DEFAULT_SQC_size;
};

void Query_Cache::print_version() {
	fprintf(stderr,"In memory Standard Query Cache (SQC) rev. %s -- %s -- %s\n", QUERY_CACHE_VERSION, __FILE__, __TIMESTAMP__);
};
static int
parentproc()
{
	int childstatus;
	unsigned long long timeoutlong=0;
	struct timeval timeout;
	int ret;
	fd_set read_fd_set;
	fd_set write_fd_set;
	fd_set except_fd_set;
	int maxfd = -1;
	struct SPDY_Daemon *daemon;
  unsigned long long  beginning = 0;
	unsigned long long now;

	SPDY_init();

	daemon = SPDY_start_daemon(port,
								DATA_DIR "cert-and-key.pem",
								DATA_DIR "cert-and-key.pem",
								&new_session_cb,
								&closed_session_cb,
								NULL,
								NULL,
								NULL,
								SPDY_DAEMON_OPTION_SESSION_TIMEOUT,
								TIMEOUT,
								SPDY_DAEMON_OPTION_END);

	if(NULL==daemon){
		printf("no daemon\n");
		return 1;
	}

	do
	{
		do_sleep=0;
		FD_ZERO(&read_fd_set);
		FD_ZERO(&write_fd_set);
		FD_ZERO(&except_fd_set);

		ret = SPDY_get_timeout(daemon, &timeoutlong);

		if(new_session && !closed_session)
		{
			if(SPDY_NO == ret)
			{
				killchild("SPDY_get_timeout returned wrong SPDY_NO");
			}
			/*if(timeoutlong)
			{
				killchild("SPDY_get_timeout returned wrong timeout");
			}*/
			now = monotonic_time ();
      if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT)
      {
        printf("Started at: %llums\n",beginning);
        printf("Now is: %llums\n",now);
        printf("Timeout is: %i\n",TIMEOUT);
        printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
        printf("SPDY_get_timeout gave: %llums\n",timeoutlong);
				killchild("Timeout passed but session was not closed");
      }
      if(timeoutlong > beginning + TIMEOUT *1000)
      {
        printf("Started at: %llums\n",beginning);
        printf("Now is: %llums\n",now);
        printf("Timeout is: %i\n",TIMEOUT);
        printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
        printf("SPDY_get_timeout gave: %llums\n",timeoutlong);
				killchild("SPDY_get_timeout returned wrong timeout");
      }
		}
		else
		{
			if(SPDY_YES == ret)
			{
				killchild("SPDY_get_timeout returned wrong SPDY_YES");
			}
		}

		if(SPDY_NO == ret || timeoutlong >= 1000)
		{
			timeout.tv_sec = 1;
      timeout.tv_usec = 0;
		}
		else
		{
			timeout.tv_sec = timeoutlong / 1000;
      timeout.tv_usec = (timeoutlong % 1000) * 1000;
		}

    //ignore values
    timeout.tv_sec = 0;
    timeout.tv_usec = SELECT_MS_TIMEOUT * 1000;

		maxfd = SPDY_get_fdset (daemon,
								&read_fd_set,
								&write_fd_set,
								&except_fd_set);

		ret = select(maxfd+1, &read_fd_set, &write_fd_set, &except_fd_set, &timeout);

		switch(ret) {
			case -1:
				printf("select error: %i\n", errno);
				break;
			case 0:
				/*if(new_session)
				{
					killchild("select returned wrong number");
				}*/
				break;
			default:
				SPDY_run(daemon);
        if(0 == beginning)
        {
	  beginning = monotonic_time ();
        }
				/*if(do_sleep)
				{
					sleep(TIMEOUT);
					do_sleep = 0;
				}*/
			break;
		}
	}
	while(waitpid(child,&childstatus,WNOHANG) != child);

	if(!new_session || !closed_session)
	{
		killchild("child is dead, callback wasn't called");
	}

	ret = SPDY_get_timeout(daemon, &timeoutlong);

	if(SPDY_YES == ret)
	{
		killchild("SPDY_get_timeout returned wrong SPDY_YES after child died");
	}

	SPDY_stop_daemon(daemon);

	SPDY_deinit();

	return 0;
}
Esempio n. 5
0
void lloyd_bgm_fade_out(struct lloyd_bgm_data *bgm) {
    bgm->fade_out_duration = lloyd.bgm_fade_out_duration;
    bgm->fade_start = monotonic_time();
    bgm->fade_state = lloyd_fade_out;
}