tstTime-3.cpp revision 230bd8589bba39933ac5ec21482d6186d675e604
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * IPRT Testcase - Simple RTTime test.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (C) 2006-2007 Oracle Corporation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This file is part of VirtualBox Open Source Edition (OSE), as
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * available from http://www.virtualbox.org. This file is free software;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * you can redistribute it and/or modify it under the terms of the GNU
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * General Public License (GPL) as published by the Free Software
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Foundation, in version 2 as it comes in the "COPYING" file of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file may alternatively be used under the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License Version 1.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * VirtualBox OSE distribution, in which case the provisions of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * CDDL are applicable instead of those of the GPL.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You may elect to license modified versions of this file under the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * terms and conditions of either the GPL or the CDDL or both.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/*******************************************************************************
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster* Header Files *
5f4d6070f856d0de82c1d16459b89233e2e81ff2Kohei Tamura*******************************************************************************/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#else /* posix */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uint64_t u64; /* manual say larger integer, should be safe to assume it's the same. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** @todo fix a different timesource on l4. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#else /* posix */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (uint64_t)tv.tv_sec * (uint64_t)(1000 * 1000 * 1000)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: usage: tstTime-3 <seconds> [seconds2 [..]]\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: Testing difference between RTTimeNanoTS() and OS time...\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int rc = RTStrToUInt64Ex(argv[i], NULL, 0, &cSeconds);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: Invalid argument %d: %s\n", i, argv[i]);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: %d - %RU64 seconds period...\n", i, cSeconds);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: %d - RT: %16RU64 ns\n", i, u64RTElapsedTS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: %d - OS: %16RU64 ns\n", i, u64OSElapsedTS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RTPrintf("tstTime-3: %d - diff: %16RI64 ns\n", i, u64RTElapsedTS - u64OSElapsedTS);