js 替换英文替换_替换CreateTimeSpan()

js 替换英文替换

…posted by davidjmedlock:

…由 davidjmedlock 发布

I was reading up on some ColdFusion optimization techniques recently for work and I came across something that said you could increase the efficiency of caching your queries by eliminating the CreateTimeSpan() function used in the CachedWithin attribute of your cfquery tags.

我最近正在阅读一些有关工作的ColdFusion优化技术,并且遇到了一些问题,即您可以消除cfquery标记的CachedWithin属性中使用的CreateTimeSpan()函数,从而提高查询缓存的效率。

Now, here’s my disclaimer: This is not really my idea. I saw it last week and for the life of me I can’t find it anywhere and I can’t remember where it was. (Seems like it was House of Fusion, but I didn’t see it in there unless I just missed it.) To the author who came up with it, if you read this let me know so I can give due credit. It’s pretty cool and I thought I’d share with our audience here.

现在,这是我的免责声明:这不是我的主意。 我上周看到了它,对我来说,我一生都找不到它,也不记得它在哪里。 (似乎是融合之屋,但直到那里我才发现它,除非我只是想念它。)对于提出这个问题的作者,如果您读过这封信,请告诉我,以便我能给予应有的荣誉。 这很酷,我想在这里与我们的观众分享。

CreateTimeSpan simply takes the days, hours, minutes, and seconds and converts them to a decimal number. This is based on days. So one day is 1, 1 day and 1 hour is 1.0416666666667 and so on. So, you can eliminate the function call to CreateTimeSpan() by doing a little junior high math on your own:

CreateTimeSpan只需花费天,小时,分钟和秒,然后将它们转换为十进制数。 这是基于天数的。 因此,一天是1、1天和1小时是1.0416666666667,依此类推。 因此,您可以自己做一些初中的数学运算,从而消除对CreateTimeSpan()的函数调用:

1 day: 1

1天:1

1 hour: 0.0416666666667

1小时:0.0416666666667

1 minute: 0.000694444444444

1分钟:0.000694444444444

1 second: 1.15740740741

1秒:1.15740740741

If you want to figure out various fractions yourself, you just have to do this:

如果您想自己计算出各种分数,则只需执行以下操作:

Hours: (h / 24) = timespan

小时:(h / 24)=时间跨度

Minutes (m / 24) / 60 = timespan

分钟(m / 24)/ 60 =时间跨度

Seconds = (s / 24) / 60 / 60 = timespan

秒=(s / 24)/ 60/60 =时间跨度

That will give you a number you can drop into cachedWithin to keep from having that additional function call. Whether this makes a noticeable difference, I can’t say. If you have a lot of cached queries, it just might, especially if they’re refreshed frequently. As with any optimization techniques, you’ll really start to notice the difference as your application grows, even though you may not see it in its infancy.

这将为您提供一个编号,您可以将其放入cachedWithin中,以免进行其他函数调用。 我不能说这是否有明显的不同。 如果您有很多缓存的查询,则可能会这样,尤其是当它们经常刷新时。 与任何优化技术一样,即使您在初期阶段都看不到它,但随着应用程序的增长,您将真正开始注意到它的不同。

Correction: To give credit where credit is due, this was actually on House of Fusion as I thought. It was actually on the one place I didn’t look: the front page. Under Optimization Overkill you’ll find more information. Thanks to author Michael Dinowitz for pointing it out.

更正:要在应得的信用额上给予信用,这实际上是我所想到的“融合之家” 。 实际上是在我没看过的地方:首页。 在Optimization Overkill下,您将找到更多信息。 感谢作者Michael Dinowitz指出这一点。

翻译自: https://www.sitepoint.com/replacing-createtimespan/

js 替换英文替换

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值