mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
adding banch mark
This commit is contained in:
parent
784a17e71b
commit
d53b2f0265
@ -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)
|
||||
|
||||
|
8
src/boot/banchmark/CMakeLists.txt
Normal file
8
src/boot/banchmark/CMakeLists.txt
Normal 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})
|
||||
# 链接src生成的lib库和gtest库
|
||||
target_link_libraries(${BINARY} PUBLIC
|
||||
${CMAKE_PROJECT_NAME}-core
|
||||
)
|
61
src/boot/banchmark/main.c
Normal file
61
src/boot/banchmark/main.c
Normal 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user