Timer Events With Notification Function

Timer Events With Notification Function

Talk is cheap, show me your code!

//
EFI_EVENT myEvent;
VOID TimerEventNotify3s(IN EFI_EVENT Event, IN VOID *Context)
{
    // static UINTN times = 0;
    Print(L"Timer Event triggerd");
}
Status = gBS->CreateEvent (
                EVT_TIMER | EVT_NOTIFY_SIGNAL,  // Type
                TPL_CALLBACK,
                (EFI_EVENT_NOTIFY)TimerEvent3s,// NotifyFunction
                (VOID*)NULL,                    // NotifyContext
                &myEvent                        // Event
                );
Status = gBS->SetTimer (
                myEvent,
                TimerRelative,
                EFI_TIMER_PERIOD_SECONDS (3)
                );
do {
      Status = gBS->CheckEvent (TimerEvent3s);
} while (EFI_ERROR (Status));

gBS->CloseEvent (TimerEvent3s);
return Status;
Python中的`with`语句可以用于创建一个上下文管理器,它可以管理资源的获取和释放。而`timer()`是一个计时器上下文管理器,用于测量执行时间。使用`with timer()`可以很方便地记录代码块的执行时间。 当使用`with timer()`时,可以在`with`语句块中编写需要计时的代码。计时器会在代码块执行前开始计时,在代码块执行结束后停止计时并打印执行时间。 例如,下面的代码使用了`with timer()`来计时一个长时间的任务: ``` with Timer('Long task') as timer: # 执行长时间的任务 sleep(1) ``` 这段代码中,使用了`with Timer('Long task') as timer`语句创建了一个计时器上下文管理器。在代码块中执行了一个长时间的任务,通过调用`sleep(1)`来模拟任务的执行。计时器会自动记录代码块的执行时间,并在代码块执行结束后打印出执行时间。 使用`with timer().child()`可以创建一个子级计时器,用于更细粒度地测量代码块的执行时间。这对于需要分析代码块中不同部分的执行时间很有用。 总之,`python with timer()`是一个方便的工具,可以帮助我们测量代码块的执行时间,并进行性能分析。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [timer-cm:用于测量执行时间的Python上下文管理器](https://download.csdn.net/download/weixin_42136477/18269275)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [python with 语句举例-计时器(timer)例子](https://blog.csdn.net/weixin_39738251/article/details/110081509)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值