int main(int argc, char* argv[])
{
    FILE *statsFile = fopen("perfstats.raw", "w");
    TfStopwatch watch;

    int recrusionSizes[] = {1, 2, 10};//, 100};
    int testSizes[] = {1000000, 10000000, 100000000};
    for (int R : recrusionSizes) {
        std::cout << "Recursion depth: " << R << std::endl;  
        for (int size : testSizes) {

            watch.Reset();
            watch.Start();
            auto collection = CreateTrace(size, R);
            watch.Stop();
            std::cout << "Create Trace    N: " << size << " time: " 
                << watch.GetSeconds() << " scopes/msec: " 
                << float(size)/watch.GetMilliseconds()
                << std::endl;

            auto reporter = TraceReporter::New(
                "Test", TraceReporterDataSourceCollection::New(collection));

            watch.Reset();
            watch.Start();
            reporter->UpdateAggregateTree();
            watch.Stop();
            WriteStats( statsFile,
                        TfStringPrintf("aggregate tree R %d N %d", R, size),
                        watch);
            std::cout << "Aggregate Tree N: " << size << " time: " 
                << watch.GetSeconds()
                << " scopes/msec: " << float(size)/watch.GetMilliseconds()
                << std::endl;

            watch.Reset();
            watch.Start();
            auto tree = TraceEventTree::New(*collection);
            watch.Stop();
            WriteStats( statsFile,
                        TfStringPrintf("event tree R %d N %d", R, size),
                        watch);
            std::cout << "Event Tree     N: " << size << " time: " 
                << watch.GetSeconds()
                << " scopes/msec: " << float(size)/watch.GetMilliseconds()
                << std::endl;
        }
    }
    fclose(statsFile);
    return 0;
}
Example #2
0
static void
Pause(double seconds)
{
    // Create a shared stopwatch named "Pause" and then
    // sleep for some number of seconds accumulating the
    // time in "Pause"
    //
    static TfStopwatch pauseWatch("pwatch", true);

    struct timespec delay;

    int64_t nanoseconds = (int64_t)(seconds * 1000000000);
    delay.tv_sec  = nanoseconds / 1000000000;
    delay.tv_nsec = nanoseconds % 1000000000;

    pauseWatch.Start();
    nanosleep(&delay, 0);
    pauseWatch.Stop();
}
// Returns the number of seconds it took to complete this operation.
double
_DoTBBTest(bool verify, const size_t arraySize, const size_t numIterations)
{
    std::vector<int> v;
    _PopulateVector(arraySize, &v);
    std::vector<int> save = v;

    TfStopwatch sw;
    sw.Start();
    std::vector<int> filterv;
    for (size_t i = 0; i < numIterations; i++) {
        v = save;
         WorkParallelSort(&v);
    }

    if (verify) {
        TF_AXIOM(numIterations == 1);
        for(unsigned int i = 1; i < v.size(); ++i){
            TF_AXIOM(v[i-1] <= v[i]);
        }
    }
    sw.Stop();
    return sw.GetSeconds();
}
// Returns the number of seconds it took to complete this operation.
double
_DoTBBTest(bool verify, const int arraySize, const size_t numIterations)
{
    std::vector<int> v;
    _PopulateVector(arraySize, v);

    TfStopwatch sw;
    sw.Start();
    int res = 0;
    for (size_t i = 0; i < numIterations; i++) {
         res = WorkParallelReduceN(0,
            arraySize,
            std::bind(&sum, _1, _2, _3, v),
            std::bind(&plus, _1, _2));
    }

    if (verify) {
        TF_AXIOM(numIterations == 1);
        TF_AXIOM(res = arraySize*(arraySize-1)/2);
    }

    sw.Stop();
    return sw.GetSeconds();
}
Example #5
0
HdTextureResourceSharedPtr
UsdImagingGL_GetTextureResource(UsdPrim const& usdPrim,
                                SdfPath const& usdPath,
                                UsdTimeCode time)
{
    if (!TF_VERIFY(usdPrim))
        return HdTextureResourceSharedPtr();
    if (!TF_VERIFY(usdPath != SdfPath()))
        return HdTextureResourceSharedPtr();

    UsdAttribute attr = _GetTextureResourceAttr(usdPrim, usdPath);
    SdfAssetPath asset;
    if (!TF_VERIFY(attr) || !TF_VERIFY(attr.Get(&asset, time))) {
        return HdTextureResourceSharedPtr();
    }

    HdTextureType textureType = HdTextureType::Uv;

    TfToken filePath = TfToken(asset.GetResolvedPath());
    // If the path can't be resolved, it's either an UDIM texture
    // or the texture doesn't exists and we can to exit early.
    if (filePath.IsEmpty()) {
        filePath = TfToken(asset.GetAssetPath());
        if (GlfIsSupportedUdimTexture(filePath)) {
            textureType = HdTextureType::Udim;
        } else {
            TF_DEBUG(USDIMAGING_TEXTURES).Msg(
                "File does not exist, returning nullptr");
            TF_WARN("Unable to find Texture '%s' with path '%s'.",
                    filePath.GetText(), usdPath.GetText());
            return {};
        }
    } else {
        if (GlfIsSupportedPtexTexture(filePath)) {
            textureType = HdTextureType::Ptex;
        }
    }

    GlfImage::ImageOriginLocation origin =
            UsdImagingGL_ComputeTextureOrigin(usdPrim);

    HdWrap wrapS = _GetWrapS(usdPrim, textureType);
    HdWrap wrapT = _GetWrapT(usdPrim, textureType);
    HdMinFilter minFilter = _GetMinFilter(usdPrim);
    HdMagFilter magFilter = _GetMagFilter(usdPrim);
    float memoryLimit = _GetMemoryLimit(usdPrim);

    TF_DEBUG(USDIMAGING_TEXTURES).Msg(
            "Loading texture: id(%s), type(%s)\n",
            usdPath.GetText(),
            textureType == HdTextureType::Uv ? "Uv" :
            textureType == HdTextureType::Ptex ? "Ptex" : "Udim");
 
    HdTextureResourceSharedPtr texResource;
    TfStopwatch timer;
    timer.Start();
    // Udim's can't be loaded through like other textures, because
    // we can't select the right factory based on the file type.
    // We also need to pass the layer context to the factory,
    // so each file gets resolved properly.
    GlfTextureHandleRefPtr texture;
    if (textureType == HdTextureType::Udim) {
        UdimTextureFactory factory(_FindLayerHandle(attr, time));
        texture = GlfTextureRegistry::GetInstance().GetTextureHandle(
            filePath, origin, &factory);
    } else {
        texture = GlfTextureRegistry::GetInstance().GetTextureHandle(
            filePath, origin);
    }

    texResource = HdTextureResourceSharedPtr(
        new HdStSimpleTextureResource(texture, textureType, wrapS, wrapT,
                                      minFilter, magFilter, memoryLimit));
    timer.Stop();

    TF_DEBUG(USDIMAGING_TEXTURES).Msg("    Load time: %.3f s\n", 
                                     timer.GetSeconds());

    return texResource;
}