| 1 | ---
|
|---|
| 2 | -- tests/tests_stress.lua
|
|---|
| 3 | --
|
|---|
| 4 | -- Stress test for Premake. Creates a large (tunable, see local variables
|
|---|
| 5 | -- at start of file) number of projects, files, and configurations. Then
|
|---|
| 6 | -- generates them all while profiling the result.
|
|---|
| 7 | --
|
|---|
| 8 | -- Run it like normal, i.e. `premake5 --file=test_stress.lua gmake`. The
|
|---|
| 9 | -- profile results will be placed at `build/profile.txt`.
|
|---|
| 10 | --
|
|---|
| 11 | -- Copyright (c) 2009-2015 Jason Perkins and the Premake project
|
|---|
| 12 | ---
|
|---|
| 13 |
|
|---|
| 14 | --
|
|---|
| 15 | -- Test parameters
|
|---|
| 16 | --
|
|---|
| 17 |
|
|---|
| 18 | local numProjects = 15
|
|---|
| 19 | local numFiles = 100
|
|---|
| 20 | local numBuildCfgs = 6
|
|---|
| 21 | local numPlatforms = 6
|
|---|
| 22 |
|
|---|
| 23 | local prjKind = "ConsoleApp"
|
|---|
| 24 | local prjLanguage = "C++"
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | --
|
|---|
| 28 | -- Generate the workspace and projects
|
|---|
| 29 | --
|
|---|
| 30 |
|
|---|
| 31 | workspace "MyWorkspace"
|
|---|
| 32 | location "build"
|
|---|
| 33 |
|
|---|
| 34 | for i = 1, numBuildCfgs do
|
|---|
| 35 | configurations ( "BuildCfg" .. i )
|
|---|
| 36 | end
|
|---|
| 37 |
|
|---|
| 38 | for i = 1, numPlatforms do
|
|---|
| 39 | platforms ( "Platform" .. i )
|
|---|
| 40 | end
|
|---|
| 41 |
|
|---|
| 42 | for i = 1, numProjects do
|
|---|
| 43 | project ("Project" .. i)
|
|---|
| 44 | location "build"
|
|---|
| 45 | kind ( prjKind )
|
|---|
| 46 | language ( prjLanguage )
|
|---|
| 47 |
|
|---|
| 48 | for j = 1, numFiles do
|
|---|
| 49 | files { "file" .. j .. ".cpp" }
|
|---|
| 50 | end
|
|---|
| 51 | end
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | --
|
|---|
| 55 | -- Install profiling extensions
|
|---|
| 56 | -- TODO: would be nice to build these into the core exe, and could be
|
|---|
| 57 | -- triggered with a flag, i.e. `premake5 --profile gmake`
|
|---|
| 58 | --
|
|---|
| 59 |
|
|---|
| 60 | dofile("pepperfish_profiler.lua")
|
|---|
| 61 | profiler = newProfiler()
|
|---|
| 62 | profiler:start()
|
|---|
| 63 |
|
|---|
| 64 | premake.override(premake.main, "postAction", function(base)
|
|---|
| 65 | base()
|
|---|
| 66 |
|
|---|
| 67 | profiler:stop()
|
|---|
| 68 |
|
|---|
| 69 | local outfile = io.open("build/profile.txt", "w+" )
|
|---|
| 70 | profiler:report(outfile)
|
|---|
| 71 | outfile:close()
|
|---|
| 72 | end)
|
|---|