当前位置: 首页>>代码示例>>C++>>正文


C++ QElapsedTimer::nsecsElapsed方法代码示例

本文整理汇总了C++中QElapsedTimer::nsecsElapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ QElapsedTimer::nsecsElapsed方法的具体用法?C++ QElapsedTimer::nsecsElapsed怎么用?C++ QElapsedTimer::nsecsElapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QElapsedTimer的用法示例。


在下文中一共展示了QElapsedTimer::nsecsElapsed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));



    cv::Mat img, img2, out, out2;
    img = cvLoadImage("Imagenes/city_night.jpeg");
    img2 = cvLoadImage("Imagenes/city_night.jpeg");
    out.create(img.size(), img.type());
    out2.create(img2.size(), img2.type());

    QElapsedTimer timer;
    qint64 nanoSec, nanoSec2;
    timer.start();

    //Lo hace todo en un solo hilo
    cv::threshold(img2,out2,66,255,1);
    nanoSec = timer.nsecsElapsed();
    qDebug() << nanoSec;

    timer.restart();

    // create 8 threads and use TBB
    cv::parallel_for_(cv::Range(0, 8), Parallel_process(img, out, 5, 8));

    nanoSec2 = timer.nsecsElapsed();
    qDebug() << nanoSec - nanoSec2;

    cv::imshow("image", out2);
    cv::imshow("blur", out);

    return app->exec();
}
开发者ID:fabianz66,项目名称:efectos-mondrian-pollock,代码行数:34,代码来源:main.cpp

示例2: show

void QSGWindowsRenderLoop::show(QQuickWindow *window)
{
    RLDEBUG("show");
    if (windowData(window) != 0)
        return;

    // This happens before the platform window is shown, but after
    // it is created. Creating the GL context takes a lot of time
    // (hundreds of milliseconds) and will prevent us from rendering
    // the first frame in time for the initial show on screen.
    // By preparing the GL context here, it is feasible (if the app
    // is quick enough) to have a perfect first frame.
    if (!m_gl) {
        QSG_RENDER_TIMING_SAMPLE(time_start);

        RLDEBUG(" - creating GL context");
        m_gl = new QOpenGLContext();
        m_gl->setFormat(window->requestedFormat());
        if (QSGContext::sharedOpenGLContext())
            m_gl->setShareContext(QSGContext::sharedOpenGLContext());
        bool created = m_gl->create();
        if (!created) {
            qWarning("QtQuick: failed to create OpenGL context");
            delete m_gl;
            m_gl = 0;
            return;
        }
        QSG_RENDER_TIMING_SAMPLE(time_created);
        RLDEBUG(" - making current");
        bool current = m_gl->makeCurrent(window);
        RLDEBUG(" - initializing SG");
        QSG_RENDER_TIMING_SAMPLE(time_current);
        if (current)
            m_rc->initialize(m_gl);

#ifndef QSG_NO_RENDER_TIMING
        if (qsg_render_timing) {
            qDebug("WindowsRenderLoop: GL=%d ms, makeCurrent=%d ms, SG=%d ms",
                   int((time_created - time_start)/1000000),
                   int((time_current - time_created)/1000000),
                   int((qsg_render_timer.nsecsElapsed() - time_current)/1000000));
        }
        if (QQmlProfilerService::enabled) {
            QQmlProfilerService::sceneGraphFrame(
                        QQmlProfilerService::SceneGraphWindowsRenderShow,
                        time_created - time_start,
                        time_current - time_created,
                        qsg_render_timer.nsecsElapsed() - time_current);
        }
#endif

    }

    WindowData data;
    data.window = window;
    data.pendingUpdate = false;
    m_windows << data;

    RLDEBUG(" - done with show");
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:60,代码来源:qsgwindowsrenderloop.cpp

示例3: preprocess

void QSGRenderer::preprocess()
{
    Q_ASSERT(m_root_node);

    // We need to take a copy here, in case any of the preprocess calls deletes a node that
    // is in the preprocess list and thus, changes the m_nodes_to_preprocess behind our backs
    // For the default case, when this does not happen, the cost is neglishible.
    QSet<QSGNode *> items = m_nodes_to_preprocess;

    for (QSet<QSGNode *>::const_iterator it = items.constBegin();
         it != items.constEnd(); ++it) {
        QSGNode *n = *it;
        if (!nodeUpdater()->isNodeBlocked(n, m_root_node)) {
            n->preprocess();
        }
    }

#ifndef QSG_NO_RENDER_TIMING
    bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled;
    if (profileFrames)
        preprocessTime = frameTimer.nsecsElapsed();
#endif

    nodeUpdater()->setToplevelOpacity(context()->renderAlpha());
    nodeUpdater()->updateStates(m_root_node);

#ifndef QSG_NO_RENDER_TIMING
    if (profileFrames)
        updatePassTime = frameTimer.nsecsElapsed();
#endif

}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:32,代码来源:qsgrenderer.cpp

示例4: test_qelapsedtimer_nsec

void test_qelapsedtimer_nsec()
{
  QElapsedTimer elapsedTimer;
  elapsedTimer.start();

  quint64 beg = elapsedTimer.nsecsElapsed();
  quint64 end;
  quint64 diff;
  for (int i = 0; i < LOOP_CNT; i++)
  {
    end = elapsedTimer.nsecsElapsed();
    diff = end - beg;
  }
  std::cout << diff /1000000 << "\t" << __func__ << std::endl;
}
开发者ID:AmesianX,项目名称:vperformance,代码行数:15,代码来源:main.cpp

示例5: checkCachePerformance

void Evnav::checkCachePerformance()
{
    QVector<int> hist(50);
    int bin = 10;

    QElapsedTimer timer;
    timer.start();
    computeDistanceHistogram(hist, bin);
    auto e1 = timer.nsecsElapsed();
    timer.restart();
    computeDistanceHistogram(hist, bin);
    auto e2 = timer.nsecsElapsed();
    qDebug() << "e1:" << e1 << "ms" << " e2:" << e2 << "ms";
    qDebug() << "hist:" << hist;
}
开发者ID:hexa00,项目名称:evnav,代码行数:15,代码来源:evnav.cpp

示例6: wait

bool QMutexPrivate::wait(int timeout)
{
    struct timespec ts, *pts = 0;
    QElapsedTimer timer;
    if (timeout >= 0) {
        ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
        ts.tv_sec = (timeout / 1000);
        pts = &ts;
        timer.start();
    }
    while (contenders.fetchAndStoreAcquire(2) > 0) {
        int r = _q_futex(&contenders._q_value, FUTEX_WAIT, 2, pts, 0, 0);
        if (r != 0 && errno == ETIMEDOUT)
            return false;

        if (pts) {
            // recalculate the timeout
            qint64 xtimeout = timeout * 1000 * 1000;
            xtimeout -= timer.nsecsElapsed();
            if (xtimeout < 0) {
                // timer expired after we returned
                return false;
            }

            ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000;
            ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000);
        }
    }
    return true;
}
开发者ID:phen89,项目名称:rtqt,代码行数:30,代码来源:qmutex_unix.cpp

示例7: printf

QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
{
    Q_D(QSGContext);
    QSGMaterialType *type = material->type();
    QSGMaterialShader *shader = d->materials.value(type);
    if (shader)
        return shader;

#ifndef QSG_NO_RENDER_TIMING
    if (qsg_render_timing  || QQmlProfilerService::enabled)
        qsg_renderer_timer.start();
#endif

    shader = material->createShader();
    shader->compile();
    shader->initialize();
    d->materials[type] = shader;

#ifndef QSG_NO_RENDER_TIMING
    if (qsg_render_timing)
        printf("   - compiling material: %dms\n", (int) qsg_renderer_timer.elapsed());

    if (QQmlProfilerService::enabled) {
        QQmlProfilerService::sceneGraphFrame(
                    QQmlProfilerService::SceneGraphContextFrame,
                    qsg_renderer_timer.nsecsElapsed());
    }
#endif

    return shader;
}
开发者ID:mortenelund,项目名称:qt,代码行数:31,代码来源:qsgcontext.cpp

示例8: elapsed

double elapsed(std::function<void ()> func)
{
    QElapsedTimer timer;
    timer.start();
    func();
    return timer.nsecsElapsed() / 1000000000.0f;
}
开发者ID:MarkZ3,项目名称:multicore,代码行数:7,代码来源:main.cpp

示例9: callFunction

	virtual QPair<qint64, double> callFunction(std::function<void()> functionToCall) const
	{
		QElapsedTimer timer;
		qint64 array[20];
		qint64 time = 0;
		qint64 expectedValue = 0;
		qint64 variance = 0;

		for (int i = 0; i < 20; ++i) {
			timer.start();
			for (int i = 0; i < 20; ++i) {
				functionToCall();
			}

			array[i] = timer.nsecsElapsed();
			time += array[i];
		}

		expectedValue = time / 20;

		for (int t = 0; t < 20; ++t) {
			variance += qPow((array[t] - expectedValue), 2);
		}

		variance = variance / 20;
		double sqrtVariance = sqrt(variance);

		QPair<qint64, double> result = qMakePair(expectedValue, sqrtVariance);
		return result;
	}
开发者ID:Antropovi,项目名称:qreal,代码行数:30,代码来源:methodsTesterForQrxcAndInterpreter.cpp

示例10: monotonicallyIncreasingTime

double monotonicallyIncreasingTime()
{
    ASSERT(QElapsedTimer::isMonotonic());
    static QElapsedTimer timer;
    if (!timer.isValid())
        timer.start();
    return timer.nsecsElapsed() / 1.0e9;
}
开发者ID:anger123520,项目名称:qtwebkit-23_from_gitorious,代码行数:8,代码来源:CurrentTime.cpp

示例11: run

void VideoExtractor::run(void)
{
    QElapsedTimer timer;
    //qint64 endOfCapture;
    //qint64 endOfHandle;
    qint64 begin;
    timer.start();
    while( ! m_stopped )
    {
        m_mutex.lock();
        while( ! m_autoPlay )
            m_cond.wait(&m_mutex);

        begin = timer.nsecsElapsed();

        m_videoStream[0]->grab(); // a for for that ... I'm too lazy
        m_videoStream[1]->grab();

        if( m_timeMax && m_timeMax > begin)
            m_autoPlay = false;

        processFrame();

        if( m_nbMaxImage && m_nbImageHandled == m_nbMaxImage )
            m_autoPlay = false;

        m_mutex.unlock();

        qint64 waitTime = ( m_paramPeriod.toInt() - timer.nsecsElapsed() + begin )/1000;
        if(waitTime < 0)
        {
            /*   std::cerr << "Warning : la boucle a du retard : " <<  waitTime
                         << "\nDuree de la boucle : " << m_paramPeriod.toInt()
                         << "\nDuree reelle : " << timer.nsecsElapsed() << std::endl; */
        }
        else
            QThread::usleep( waitTime );
    }

    emit finished();
    deleteLater();
}
开发者ID:Alexandro960,项目名称:ProjetSI2,代码行数:42,代码来源:videoextractor.cpp

示例12: computeStarPositions

void Generator::computeStarPositions(InputVertices& destination, unsigned limit, unsigned seed) {
    InputVertices* vertices = & destination;
    //_limit = limit;
    
    QElapsedTimer startTime;
    startTime.start();
    
    srand(seed);
    
    vertices->clear();
    vertices->reserve(limit);
    
    const unsigned MILKY_WAY_WIDTH = 12.0; // width in degrees of one half of the Milky Way
    const float MILKY_WAY_INCLINATION = 0.0f; // angle of Milky Way from horizontal in degrees
    const float MILKY_WAY_RATIO = 0.4f;
    const unsigned NUM_DEGREES = 360;
    
    for(int star = 0; star < floor(limit * (1 - MILKY_WAY_RATIO)); ++star) {
        float azimuth, altitude;
        azimuth = (((float)rand() / (float) RAND_MAX) * NUM_DEGREES) - (NUM_DEGREES / 2);
        altitude = (acos((2.0f * ((float)rand() / (float)RAND_MAX)) - 1.0f) / PI_OVER_180) + 90;
        vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
    }
    
    for(int star = 0; star < ceil(limit * MILKY_WAY_RATIO); ++star) {
        float azimuth = ((float)rand() / (float) RAND_MAX) * NUM_DEGREES;
        float altitude = powf(randFloat()*0.5f, 2.0f)/0.25f * MILKY_WAY_WIDTH;
        if (randFloat() > 0.5f) {
            altitude *= -1.0f;
        }
        
        // we need to rotate the Milky Way band to the correct orientation in the sky
        // convert from spherical coordinates to cartesian, rotate the point and then convert back.
        // An improvement would be to convert all stars to cartesian at this point and not have to convert back.
        
        float tempX = sin(azimuth * PI_OVER_180) * cos(altitude * PI_OVER_180);
        float tempY = sin(altitude * PI_OVER_180);
        float tempZ = -cos(azimuth * PI_OVER_180) * cos(altitude * PI_OVER_180);
        
        float xangle = MILKY_WAY_INCLINATION * PI_OVER_180;
        float newX = (tempX * cos(xangle)) - (tempY * sin(xangle));
        float newY = (tempX * sin(xangle)) + (tempY * cos(xangle));
        float newZ = tempZ;
        
        azimuth = (atan2(newX,-newZ) + Radians::pi()) / PI_OVER_180;
        altitude = atan2(-newY, hypotf(newX, newZ)) / PI_OVER_180;
        
        vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
    }
    
    double timeDiff = (double)startTime.nsecsElapsed() / 1000000.0; // ns to ms
    qDebug() << "Total time to generate stars: " << timeDiff << " msec";
}
开发者ID:DaveDubUK,项目名称:hifi,代码行数:53,代码来源:Generator.cpp

示例13: time_it

double time_it(std::function<void ()> fn)
{
    QElapsedTimer timer;

    // warm-up
    fn();

    timer.start();
    fn();
    ulong elapsed = timer.nsecsElapsed();
    return (double) elapsed / 1000000000.0;
}
开发者ID:MarkZ3,项目名称:multicore,代码行数:12,代码来源:main.cpp

示例14: render

/*
 * Go through all windows we control and render them in turn.
 * Then tick animations if active.
 */
void QSGWindowsRenderLoop::render()
{
    RLDEBUG("render");
    foreach (const WindowData &wd, m_windows) {
        if (wd.pendingUpdate) {
            const_cast<WindowData &>(wd).pendingUpdate = false;
            renderWindow(wd.window);
        }
    }

    if (m_animationDriver->isRunning()) {
        RLDEBUG("advancing animations");
        QSG_RENDER_TIMING_SAMPLE(time_start);
        m_animationDriver->advance();
        RLDEBUG("animations advanced");

#ifndef QSG_NO_RENDER_TIMING
        if (qsg_render_timing) {
            qDebug("WindowsRenderLoop: animations=%d ms",
                   int((qsg_render_timer.nsecsElapsed() - time_start)/1000000));
        }
        if (QQmlProfilerService::Enabled) {
            QQmlProfilerService::sceneGraphFrame(
                        QQmlProfilerService::SceneGraphWindowsAnimations,
                        qsg_render_timer.nsecsElapsed() - time_start);
        }
#endif

        // It is not given that animations triggered another maybeUpdate()
        // and thus another render pass, so to keep things running,
        // make sure there is another frame pending.
        maybePostUpdateTimer();

        emit timeToIncubate();
    }
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:40,代码来源:qsgwindowsrenderloop.cpp

示例15:

void Mesh3D::calcMassProps(const float density, const XMFLOAT3& scale, XMFLOAT3X3& inertiaTensor, XMFLOAT3& centerOfMass, float* mass) const
{
	std::vector<float> inertia;
	std::vector<float> com; // center of mass
	std::vector<float> scaling{ scale.x, scale.y, scale.z };

	QElapsedTimer timer;
	timer.start();
	VolInt::calcMassProps(m_indexData, m_vertexData, scaling, density, inertia, com, mass, nullptr);
	OutputDebugStringA(("Elapsed Volume Integration: " + std::to_string(timer.nsecsElapsed() * 0.000001) + "msec\n").c_str());

	inertiaTensor = XMFLOAT3X3(inertia.data());
	centerOfMass = { com[0], com[1], com[2] };

}
开发者ID:gudajan,项目名称:Windsim,代码行数:15,代码来源:mesh3D.cpp


注:本文中的QElapsedTimer::nsecsElapsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。