test_stress.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. -- Test parameters
  15. --
  16. local numProjects = 15
  17. local numFiles = 100
  18. local numBuildCfgs = 6
  19. local numPlatforms = 6
  20. local prjKind = "ConsoleApp"
  21. local prjLanguage = "C++"
  22. --
  23. -- Generate the workspace and projects
  24. --
  25. workspace "MyWorkspace"
  26. location "build"
  27. for i = 1, numBuildCfgs do
  28. configurations ( "BuildCfg" .. i )
  29. end
  30. for i = 1, numPlatforms do
  31. platforms ( "Platform" .. i )
  32. end
  33. for i = 1, numProjects do
  34. project ("Project" .. i)
  35. location "build"
  36. kind ( prjKind )
  37. language ( prjLanguage )
  38. for j = 1, numFiles do
  39. files { "file" .. j .. ".cpp" }
  40. end
  41. end
  42. --
  43. -- Install profiling extensions
  44. -- TODO: would be nice to build these into the core exe, and could be
  45. -- triggered with a flag, i.e. `premake5 --profile gmake`
  46. --
  47. dofile("pepperfish_profiler.lua")
  48. profiler = newProfiler()
  49. profiler:start()
  50. premake.override(premake.main, "postAction", function(base)
  51. base()
  52. profiler:stop()
  53. local outfile = io.open("build/profile.txt", "w+" )
  54. profiler:report(outfile)
  55. outfile:close()
  56. end)