函式中使用棧與使用堆時函式執行效率淺對比

2021-08-17 11:04:44 字數 621 閱讀 1367

函式1,

void uart_net_send(struct tls_uart *uart, u32 head, u32 tail, int count)

memcpy(uart_net_send_data, recv->buf + tail, buflen);

函式2,

void uart_net_send(struct tls_uart *uart, u32 head, u32 tail, int count)

;if (count >= uart_net_send_data_size)

memcpy(uart_net_send_data, recv->buf + tail, buflen);

函式3,

void uart_net_send(struct tls_uart *uart, u32 head, u32 tail, int count)

memcpy(uart_net_send_data, recv->buf + tail, buflen);

函式uart_net_send()是乙個需要快速執行完畢的函式,它的執行時間越短,裝置的**資料的速度就越快,執行效率就越高。

經實驗,在以上三個函式實現中,函式3最慢,函式1最快。

協議棧中使用crc校驗函式

include intmain 以乙個7個位元組的陣列舉例 inti 0 j 0 cc 0xffff for i 0 i 7 i else printf d cc 輸出10進製crc校驗值 printf n printf x cc 輸出16進製制的crc校驗值 這時會看到,資料顯示不正確,按照思路同...

makefile中使用函式

一 編譯需要的檔案 1 file1.h ifndef file1 h define file1 h ifdef cplusplus extern c endif endif2 file1.cpp include include file1.h using namespace std void fil...

Vue render 函式中使用this

1.在render中直接使用this,on裡面click函式不是箭頭函式 使用this需要在父級將this儲存起來才能使用 render h,params params let this this return h div style on this.previewurl row.picture t...