Predicted transactions

本文探讨了处理连续输入数据的两种模型:通过设置定时器扩展执行时间以响应每个新任务,或在沉默期收集输入并在定时器结束时执行任务,以优化资源使用和效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When you put something into a dynamic array, it won't grow by just 1 when reaching the limit.  This is important because changing size is an expensive operation.

 

For example if I have a job to execute, and the input data just keep coming and coming every now and then.

 

There could be 2 models for this: 

 

Solution #1: Keep a timeout for the job, extend the execution time by fixed time(such as 1s)  every time we received a new job. When timeout is reached, execute the job. 

When a new input come, and there's no existing job available, we simple create a new job

 

Solution #2: Keep a timeout for the tob, before execution, collect new inputs, before execution in the last second, mark it as silent period. If we have new input coming in the silent period, do not execute the job, request another spin of time as the timeout is defined.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值