summaryrefslogtreecommitdiffstats
path: root/tools/slang-profile/slang-profile-main.cpp
blob: 08e74a350a24168957d4d87e5a3e71bccb79a39c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// slang-profile-main.cpp

#include "../../source/core/slang-io.h"
#include "../../source/core/slang-process-util.h"
#include "../../source/core/slang-std-writers.h"
#include "../../source/core/slang-string-util.h"
#include "slang-com-helper.h"

using namespace Slang;

SlangResult innerMain(int argc, char** argv)
{
    auto stdWriters = StdWriters::initDefaultSingleton();

    // Time the creation of the session
    {
        const auto startTick = Process::getClockTick();

        for (Int i = 0; i < 32; ++i)
        {
            ComPtr<slang::IGlobalSession> slangSession;
            slangSession.attach(spCreateSession(nullptr));
        }

        const auto endTick = Process::getClockTick();

        printf("Ticks %f\n", double(endTick - startTick) / Process::getClockFrequency());
        return SLANG_OK;
    }

    return SLANG_OK;
}

int main(int argc, char** argv)
{
    const SlangResult res = innerMain(argc, argv);
#ifdef _MSC_VER
    _CrtDumpMemoryLeaks();
#endif
    return SLANG_SUCCEEDED(res) ? 0 : 1;
}