adding banch mark

This commit is contained in:
lyon tab s7 2021-08-21 17:42:00 +08:00
parent 784a17e71b
commit d53b2f0265
4 changed files with 72 additions and 0 deletions

View File

@ -10,4 +10,5 @@ add_subdirectory(src/boot/demo02-add)
add_subdirectory(src/boot/demo03-usart)
add_subdirectory(src/boot/demo04-usarts)
add_subdirectory(src/boot/demo05-sysobject)
add_subdirectory(src/boot/banchmark)

View File

@ -0,0 +1,8 @@
set(BINARY ${CMAKE_PROJECT_NAME}_banchmark)
file(GLOB_RECURSE THIS_SOURCES LIST_DIRECTORIES false *.h *.cpp *.c)
set(SOURCES ${THIS_SOURCES})
add_executable(${BINARY} ${THIS_SOURCES})
# srclibgtest
target_link_libraries(${BINARY} PUBLIC
${CMAKE_PROJECT_NAME}-core
)

61
src/boot/banchmark/main.c Normal file
View File

@ -0,0 +1,61 @@
/* this demo shows the usage of method */
#include "BaseObj.h"
#include <stdio.h>
void onMethod(MimiObj *self, Args *args)
{
/* turn on the led */
printf("the led is on! \r\n");
}
void offMethod(MimiObj *self, Args *args)
{
/* turn off the led */
printf("the led is off! \r\n");
}
MimiObj *New_LED(Args *args)
{
/* Derive from the tiny object class.
Tiny object can not import sub object.
Tiny object is the smallest object. */
MimiObj *self = New_TinyObj(args);
/* bind the method */
class_defineMethod(self, "on()", onMethod);
class_defineMethod(self, "off()", offMethod);
/* return the object */
return self;
}
MimiObj *New_MYROOT(Args *args)
{
/* Derive from the base object class .
BaseObj is the smallest object that can
import sub object. */
MimiObj *self = New_BaseObj(args);
/* import LED class */
obj_import(self, "LED", New_LED);
/* new led object bellow root object */
obj_newObj(self, "led", "LED");
/* return the object */
return self;
}
extern DMEM_STATE DMEMS;
int32_t main()
{
/* new root object */
MimiObj *root = newRootObj("root", New_MYROOT);
/* user input buff */
char inputBuff[256] = {0};
/* run the script with check*/
obj_run(root, "led.on()");
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum*DMEM_BLOCK_SIZE/1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num*DMEM_BLOCK_SIZE/1024.0);
}

2
test Normal file
View File

@ -0,0 +1,2 @@
sh make.sh
build/src/boot/banchmark/pikascript_banchmark