Added a window creation speed test. Can test empty windows or windows
with BBoxes within. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
079c69cbfd
commit
ecef598e73
@ -177,3 +177,4 @@ SubInclude HAIKU_TOP src tests servers app scrolling ;
|
||||
SubInclude HAIKU_TOP src tests servers app stress_test ;
|
||||
SubInclude HAIKU_TOP src tests servers app textview ;
|
||||
SubInclude HAIKU_TOP src tests servers app view_state ;
|
||||
SubInclude HAIKU_TOP src tests servers app window_creation ;
|
||||
|
13
src/tests/servers/app/window_creation/Jamfile
Normal file
13
src/tests/servers/app/window_creation/Jamfile
Normal file
@ -0,0 +1,13 @@
|
||||
SubDir HAIKU_TOP src tests servers app window_creation ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
Application WindowCreation :
|
||||
main.cpp
|
||||
: be
|
||||
;
|
||||
|
151
src/tests/servers/app/window_creation/main.cpp
Normal file
151
src/tests/servers/app/window_creation/main.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <OS.h>
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static BRect *sFrames = NULL;
|
||||
static uint32 sNumFrames = 0;
|
||||
|
||||
|
||||
class TestApp : public BApplication {
|
||||
public:
|
||||
TestApp(uint32 numWindows, bool views);
|
||||
virtual ~TestApp();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
|
||||
private:
|
||||
uint32 fFrameNum;
|
||||
BRect fScreenFrame;
|
||||
uint32 fNumWindows;
|
||||
uint32 fMaxWindows;
|
||||
bool fTestViews;
|
||||
|
||||
void _CreateFrames(uint32 numWindows);
|
||||
int32 _WindowCreator();
|
||||
static int32 _ThreadStarter(void *data);
|
||||
};
|
||||
|
||||
|
||||
class TestWindow : public BWindow {
|
||||
public:
|
||||
TestWindow(BRect frame, bool createView);
|
||||
virtual ~TestWindow();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
TestApp::TestApp(uint32 numWindows, bool views)
|
||||
: BApplication("application/x.vnd-Haiku.window-creation"),
|
||||
fScreenFrame(),
|
||||
fNumWindows(0),
|
||||
fMaxWindows(numWindows),
|
||||
fTestViews(views)
|
||||
|
||||
{
|
||||
fScreenFrame = BScreen().Frame();
|
||||
_CreateFrames(numWindows);
|
||||
}
|
||||
|
||||
|
||||
TestApp::~TestApp()
|
||||
{
|
||||
delete[] sFrames;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TestApp::ReadyToRun()
|
||||
{
|
||||
thread_id thread = spawn_thread(_ThreadStarter, "Window creator", B_NORMAL_PRIORITY, this);
|
||||
resume_thread(thread);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TestApp::_CreateFrames(uint32 numWindows)
|
||||
{
|
||||
BRect frame(0, 0, 50, 50);
|
||||
uint32 numHorizontal = (fScreenFrame.IntegerWidth() + 1) / (frame.IntegerWidth() + 1);
|
||||
uint32 numVertical = (fScreenFrame.IntegerHeight() + 1) / (frame.IntegerHeight() + 1);
|
||||
sNumFrames = numHorizontal * numVertical;
|
||||
sFrames = new BRect[sNumFrames];
|
||||
for (int32 i = 0; i < sNumFrames; i++) {
|
||||
sFrames[i] = frame;
|
||||
frame.OffsetBy(50, 0);
|
||||
if (!fScreenFrame.Contains(frame))
|
||||
frame.OffsetTo(0, frame.bottom + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TestApp::_WindowCreator()
|
||||
{
|
||||
bigtime_t startTime = system_time();
|
||||
|
||||
while (fNumWindows < fMaxWindows) {
|
||||
if (fFrameNum >= sNumFrames)
|
||||
fFrameNum = 0;
|
||||
|
||||
BWindow *window = new TestWindow(sFrames[fFrameNum++], fTestViews);
|
||||
window->Show();
|
||||
fNumWindows++;
|
||||
}
|
||||
|
||||
bigtime_t endTime = system_time();
|
||||
|
||||
printf("Test completed. %ld windows created in %lld usecs.\n", fNumWindows, endTime - startTime);
|
||||
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TestApp::_ThreadStarter(void *data)
|
||||
{
|
||||
return static_cast<TestApp *>(data)->_WindowCreator();
|
||||
}
|
||||
|
||||
|
||||
TestWindow::TestWindow(BRect frame, bool views)
|
||||
: BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
if (views)
|
||||
AddChild(new BBox(Bounds()));
|
||||
}
|
||||
|
||||
|
||||
TestWindow::~TestWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
// main
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
uint32 numWindows = 10;
|
||||
bool testViews = false;
|
||||
if (argc > 1) {
|
||||
numWindows = atoi(argv[1]);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if (!strcmp(argv[2], "views"))
|
||||
testViews = true;
|
||||
}
|
||||
|
||||
TestApp app(numWindows, testViews);
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user