显然在EC2上,local hash = {
["mn"] = { ["index"] = 7, ["key"] = "mn", ["score"] = 0 },
["kl"] = { ["index"] = 6, ["key"] = "kl", ["score"] = .4 },
["ef"] = { ["index"] = 3, ["key"] = "ef", ["score"] = .3 },
["ab"] = { ["index"] = 1, ["key"] = "ab", ["score"] = 0 },
["cd"] = { ["index"] = 2, ["key"] = "cd", ["score"] = .1 },
["gh"] = { ["index"] = 4, ["key"] = "gh", ["score"] = 0 },
["ij"] = { ["index"] = 5, ["key"] = "ij", ["score"] = .2 }
}
local tbl = {}
for _,v in pairs(hash) do
table.insert(tbl, v)
end
table.sort(tbl, function(a,b)
return a.score > b.score or a.score == b.score and a.index < b.index
end)
系统调用不能像在裸机上那样使用vDSO机制。
https://blog.packagecloud.io/eng/2017/03/08/system-calls-are-much-slower-on-ec2/
在我的应用程序中,我使用gettimeofday
来衡量运行时指标所用的时间。该应用程序在其他方面进行了相当优化,这些系统调用的成本相当高。
鉴于没有必要获得实际时间而只需要经过时间的增量,是否有其他机制可以获得不需要系统调用的经过时间?并且最好是一个不涉及改变系统范围设置的设备,这可能会损害系统其余部分的时间源?