> For the complete documentation index, see [llms.txt](https://freeioe.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://freeioe.gitbook.io/doc/reference/other/utils/timer.md).

# 周期计时模块

***

## 计时模块

用以周期计时模块

```
API_VER: 6 
```

### new

构造函数

```lua
function summation:new(callback, span, integral_time)
end
```

* callback\
  回调函数，当时间到达计时周期时，会回调这个函数。
* span\
  周期时间（秒）
* integral\_time\
  boolean, 是否采取整点时间回调，否则会从当前时间开始计时(调用start的时间)。

回调函数的原型是

```lua
--- now 是当前时间
function(now)
end
```

当span是60， integral\_time为true时，回调函数会在没分钟的0秒时回调callback函数。 模块只能尽可能满足这个整点时间要求，但是具体的时间有可能会晚于0秒时间。 具体时间差异要收到操作系统调度，以及使用此模块的应用进程内是否有其他比较耗时操作的影响。

### start

开启计时

```lua
function summation:start()
end
```

### stop

停止周期计时

```lua
function summation:stop()
end
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://freeioe.gitbook.io/doc/reference/other/utils/timer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
