本文整理汇总了C++中TIME函数的典型用法代码示例。如果您正苦于以下问题:C++ TIME函数的具体用法?C++ TIME怎么用?C++ TIME使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q
void FB_TOF::executeEvent(int pa_nEIID){
if(scm_nEventREQID == pa_nEIID){
if(IN() == true){
Q() = true;
ET() = 0;
fallingEdge = false;
notFirstRisingEdge = true;
start = 0;
}
else{
if(true == notFirstRisingEdge){
if(fallingEdge == false){
fallingEdge = true;
start = TIME();
}
else{
count = TIME() - start;
if(PT() <= count){
Q() = false;
ET() = PT();
}else{
ET() = count;
}
}
}
}
sendOutputEvent(scm_nEventCNFID);
}
}
示例2: main
int
main (int argc, char **argv)
{
mp_ptr r1p, r2p, s1p, s2p;
double t;
mp_size_t n;
n = strtol (argv[1], 0, 0);
r1p = malloc (n * BYTES_PER_MP_LIMB);
r2p = malloc (n * BYTES_PER_MP_LIMB);
s1p = malloc (n * BYTES_PER_MP_LIMB);
s2p = malloc (n * BYTES_PER_MP_LIMB);
TIME (t,(mpn_add_n(r1p,s1p,s2p,n),mpn_sub_n(r1p,s1p,s2p,n)));
printf (" separate add and sub: %.3f\n", t);
TIME (t,mpn_addsub_n(r1p,r2p,s1p,s2p,n));
printf ("combined addsub separate variables: %.3f\n", t);
TIME (t,mpn_addsub_n(r1p,r2p,r1p,s2p,n));
printf (" combined addsub r1 overlap: %.3f\n", t);
TIME (t,mpn_addsub_n(r1p,r2p,r1p,s2p,n));
printf (" combined addsub r2 overlap: %.3f\n", t);
TIME (t,mpn_addsub_n(r1p,r2p,r1p,r2p,n));
printf (" combined addsub in-place: %.3f\n", t);
return 0;
}
示例3: Q
void FB_TP::executeEvent(int pa_nEIID){
if(pa_nEIID == scm_nEventREQID){
if (edgeFlag) {
if(ET() >= PT()){
Q() = false;
edgeFlag = false;
DEVLOG_DEBUG("top\n");
}else{
ET() = TIME() - start;
DEVLOG_DEBUG("rising\n");
}
}
else {
if(IN() == true && ET() == 0){
Q() = true;
edgeFlag = true;
start = TIME();
DEVLOG_DEBUG("start\n");
}
else
if((false == IN()) && (ET()>0)) {
ET() = 0;
DEVLOG_DEBUG("reset\n");
}
}
sendOutputEvent(scm_nEventCNFID);
}
}
示例4: benchmark_inc_longlong
double
benchmark_inc_longlong (struct pe_vars v, union data_types *buffer,
unsigned long iterations)
{
int64_t begin, end;
int i;
static double rate = 0, sum_rate = 0, lat = 0, sum_lat = 0;
/*
* Touch memory
*/
memset(buffer, CHAR_MAX * drand48(), sizeof(union data_types
[ITERATIONS]));
shmem_barrier_all();
if (v.me < v.pairs) {
begin = TIME();
for (i = 0; i < iterations; i++) {
shmem_longlong_inc(&(buffer[i].longlong_type), v.nxtpe);
}
end = TIME();
rate = ((double)iterations * 1e6) / (end - begin);
lat = (end - begin) / (double)iterations;
}
shmem_double_sum_to_all(&sum_rate, &rate, 1, 0, 0, v.npes, pwrk1, psync1);
shmem_double_sum_to_all(&sum_lat, &lat, 1, 0, 0, v.npes, pwrk2, psync2);
print_operation_rate(v.me, "shmem_longlong_inc", sum_rate/1e6, sum_lat/v.pairs);
return 0;
}
示例5: main
int main(int argc, char * argv[])
{
int argi;
long long loops = 1000000000;
int do_vararg = 0;
int do_fixarg = 0;
int vals[10] = { 0,1,2,3,4,5,6,7,8,9 };
for (argi = 1; argi < argc; argi++) {
const char *word = argv[argi];
if (word[0] != '-' || !word[1] || word[2])
help(1);
switch (word[1]) {
case 'l':
word = argv[++argi];
loops = atoll(word);
break;
case 'v':
do_vararg = 1;
break;
case 'a':
do_fixarg = 1;
break;
default:
help(1);
}
}
if (do_vararg)
TIME("vararg", run_vararg(loops,vals));
if (do_fixarg)
TIME("fixed", run_fixarg(loops,vals));
return 0;
}
示例6: message_rate
double
message_rate (struct pe_vars v, long * buffer, int size, int iterations)
{
int64_t begin, end;
int i, offset;
/*
* Touch memory
*/
memset(buffer, size, sizeof(long) * MAX_MSG_SZ * ITERS_LARGE);
shmem_barrier_all();
if (v.me < v.pairs) {
begin = TIME();
for (i = 0, offset = 0; i < iterations; i++, offset += size) {
//shmem_putmem(&buffer[offset], &buffer[offset], size, v.nxtpe);
shmem_long_put(&buffer[offset], &buffer[offset], size, v.nxtpe);
}
shmem_fence(v.nxtpe);
//shmem_quiet();
end = TIME();
return ((double)iterations * 1e6) / ((double)end - (double)begin);
}
return 0;
}
示例7: main
int
main(int argc, char **argv)
{
struct timeval stv, etv;
const char * const *engines;
for (unsigned int i = START; i <= END; i *= 10) {
gettimeofday(&stv, NULL);
for (unsigned int j = 0; j < i; j++)
i += (uintptr_t) test_return(NULL, NULL);
gettimeofday(&etv, NULL);
printf(RFMT, "return", i, TIME(stv, etv), 0);
}
engines = ql_engine_list();
assert(engines);
for (unsigned int i = 0; engines[i]; i++) {
qlParameter param;
qlState *state;
for (unsigned int j = START; j <= END; j *= 10) {
gettimeofday(&stv, NULL);
for (unsigned int k = 0; k < j / YIELDS; k++) {
state = ql_state_new(NULL, engines[i], test_yield, 0);
while (ql_state_step(state, ¶m))
continue;
}
gettimeofday(&etv, NULL);
printf(FMT, engines[i], "yield", j, TIME(stv, etv), j / YIELDS * 2);
}
}
return 0;
}
示例8: bulk_test
void bulk_test(int iters) {GASNET_BEGIN_FUNCTION();
int i;
int64_t begin, end;
stat_struct_t stput;
int payload;
for (payload = min_payload; payload <= max_payload && payload > 0; payload *= 2) {
init_stat(&stput, payload);
BARRIER();
if (iamsender) {
/* measure the throughput of sending a message */
begin = TIME();
for (i = 0; i < iters; i++) {
gasnet_memset(peerproc, tgtmem, 0xaa, payload);
}
end = TIME();
update_stat(&stput, (end - begin), iters);
}
BARRIER();
if (iamsender) {
print_stat(myproc, &stput, "memset throughput", PRINT_THROUGHPUT);
}
}
}
示例9: bulk_test_nb
void bulk_test_nb(int iters) {GASNET_BEGIN_FUNCTION();
int i;
int64_t begin, end;
stat_struct_t stput;
gasnet_handle_t *handles;
int payload;
handles = (gasnet_handle_t *) test_malloc(sizeof(gasnet_handle_t) * iters);
for (payload = min_payload; payload <= max_payload && payload > 0; payload *= 2) {
init_stat(&stput, payload);
BARRIER();
if (iamsender) {
/* measure the throughput of sending a message */
begin = TIME();
for (i = 0; i < iters; i++) {
handles[i] = gasnet_memset_nb(peerproc, tgtmem, 0x5a, payload);
}
gasnet_wait_syncnb_all(handles, iters);
end = TIME();
update_stat(&stput, (end - begin), iters);
}
BARRIER();
if (iamsender) {
print_stat(myproc, &stput, "memset_nb throughput", PRINT_THROUGHPUT);
}
}
test_free(handles);
}
示例10: Q
void FB_TON::executeEvent(int pa_nEIID){
if(scm_nEventREQID == pa_nEIID){
if(IN() == false){
Q() = false;
ET() = 0;
risingEdge = false;
start = 0;
}
else{
if(risingEdge == false){
risingEdge = true;
start = TIME();
}else{
count = TIME() - start;
if(PT() <= count){
Q() = true;
ET() = PT();
}else{
ET() = count;
}
}
}
sendOutputEvent(scm_nEventCNFID);
}
}
示例11: message_rate
double message_rate (long * buffer, int size, int iterations, int me, int pairs, int nxtpe, MPI_Win win)
{
int64_t begin, end;
int i, offset;
/*
* Touch memory
*/
memset(buffer, size, MAX_MSG_SZ * ITERS_LARGE * sizeof(long));
MPI_Barrier(MPI_COMM_WORLD);
if (me < pairs) {
begin = TIME();
for (i = 0, offset = 0; i < iterations; i++, offset++) {
MPI_Put ((buffer + offset*size), size, MPI_LONG, nxtpe, offset*size, size, MPI_LONG, win);
//MPI_Win_flush_local (nxtpe, win);
}
//MPI_Win_flush_all(win);
MPI_Win_flush(nxtpe, win);
end = TIME();
return ((double)iterations * 1e6) / ((double)end - (double)begin);
}
return 0;
}
示例12: main
int main (int argc, char** argvs) {
//Check number of arguments
if(argc != 2){
printf("Expected 1 argument to commandline.\n");
exit(-1);
}
//Read in AST
char* filename = argvs[1];
ScopeStmt* stmt = read_ast(filename);
//Compile to bytecode
Program* program = compile(stmt);
//Read in bytecode
//Program* program = load_bytecode(argvs[1]);
//Interpret bytecode
#ifdef DEBUG
TIME_T t1, t2;
FREQ_T freq;
FREQ(freq);
TIME(t1);
#endif
interpret_bc(program);
#ifdef DEBUG
TIME(t2);
double interp_time = ELASPED_TIME(t1, t2, freq);
fprintf(stderr, "Interpret Time: %.4lf ms.\n", interp_time);
#endif
}
示例13: main
int main()
{
TIME(hweight64_time());
TIME(hweight32_time());
printf("passed\n");
return 0;
}
示例14: main
int main (int argc, char *argv[])
{
int i, ret;
int size, is_server;
double t_start = 0.0, t_end = 0.0;
double latency;
struct iovec s_iov, r_iov;
uintptr_t peer_addr;
int peer_pid;
if (allocate_memory(&s_buf, &r_buf)) {
/* Error allocating memory */
exit(-1);
}
is_server = (argc == 1);
if (is_server) {
fprintf(stderr, "server ready: %d, %p\n", getpid(), r_buf);
while (1);
}
peer_pid = atoi(argv[1]);
peer_addr = (uintptr_t) strtol(argv[2], NULL, 16);
s_iov.iov_base = s_buf;
r_iov.iov_base = (void *) peer_addr;
print_header();
/* Latency test */
for(size = 0; size <= MAX_MSG_SIZE; size = (size ? size * 2 : 1)) {
touch_data(s_buf, r_buf, size);
if(size > LARGE_MESSAGE_SIZE) {
loop = LOOP_LARGE;
skip = SKIP_LARGE;
}
for(i = 0; i < loop + skip; i++) {
if(i == skip)
t_start = TIME();
s_iov.iov_len = r_iov.iov_len = size;
ret = process_vm_writev(peer_pid,
&s_iov, 1,
&r_iov, 1, 0);
if (ret != size) {
fprintf(stderr, "process_vm_writev failed: %d\n", ret);
exit(-1);
}
}
t_end = TIME();
latency = (1.0 * (t_end-t_start)) / loop;
fprintf(stderr, "%-*d%*.*f\n", 10, size, FIELD_WIDTH,
FLOAT_PRECISION, latency);
}
return 0;
}
示例15: test_malloc
void *thread_main(void *arg) {
thread_data_t *td = (thread_data_t*) arg;
int i;
int64_t start,total;
#if GASNET_PAR
gasnet_image_t *imagearray = test_malloc(nodes * sizeof(gasnet_image_t));
for (i=0; i<nodes; ++i) { imagearray[i] = threads_per_node; }
gasnet_coll_init(imagearray, td->mythread, NULL, 0, 0);
test_free(imagearray);
#else
gasnet_coll_init(NULL, 0, NULL, 0, 0);
#endif
MYBARRIER();
if (td->mythread == 0) {
printf("Running barrier test with %i iterations...\n",iters);
fflush(stdout);
}
MYBARRIER();
start = TIME();
for (i=0; i < iters; i++) {
gasnet_coll_barrier_notify(GASNET_TEAM_ALL, i, GASNET_BARRIERFLAG_IMAGES);
GASNET_Safe(gasnet_coll_barrier_wait(GASNET_TEAM_ALL, i, GASNET_BARRIERFLAG_IMAGES));
}
total = TIME() - start;
MYBARRIER();
if (td->mythread == 0) {
printf("Total time: %8.3f sec Avg Named Barrier latency: %8.3f us\n",
((float)total)/1000000, ((float)total)/iters);
fflush(stdout);
}
MYBARRIER();
start = TIME();
for (i=0; i < iters; i++) {
gasnet_coll_barrier_notify(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS | GASNET_BARRIERFLAG_IMAGES);
GASNET_Safe(gasnet_coll_barrier_wait(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS | GASNET_BARRIERFLAG_IMAGES));
}
total = TIME() - start;
MYBARRIER();
if (td->mythread == 0) {
printf("Total time: %8.3f sec Avg Anon. Barrier latency: %8.3f us\n",
((float)total)/1000000, ((float)total)/iters);
fflush(stdout);
}
MYBARRIER();
return NULL;
}