代码片段

论坛 期权论坛 脚本     
已经匿名di用户   2022-5-29 19:11   1490   0
#! /bin/sh
echo $0
echo $1
echo $@
echo $#

andy$./test.sh 1 2 3 4 .
/test.sh 1 1 2 3 4 4
print(select('#', ...))
print(select(2, ...))
local arg = select(2, ...)
print("arg=" .. arg)

andy$ lua test.lua 1 2 3
3
2    3
arg=2
for k, v in pairs(table) do
    print("key = " .. k .. ", value = " .. v)
end

//c++11 get elapsed time
#include <chrono> auto last_time = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now(); auto elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_time);
if(elapsed_time.count() > 100) {//do sth}

#include <sstream>

std::ostringstream os; os
<< memory.uMemoryUsed; obj["uMemoryUsed"] = os.str(); //os.clear(); this method doesn't clear the buffer... clear : clears error and eof flags os.str(""); os << memory.uMemoryTotal; obj["uMemoryTotal"] = os.str(); os.str(""); os << memory.uProcessMemroyUsed; obj["uProcessMemroyUsed"] = os.str();

转载于:https://www.cnblogs.com/awiki/p/5965368.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP