程序的内存和速度在 Chrome 等网络浏览器中有何关系?
最近,我一直在研究 R(5,5) 的拉姆齐定理。您可以在此处查看之前尝试的一些示例:http://zacharymaril.com/thoughts/constructionGraph.html 本质:找到图中的所有 k4 或其补集,然后以不形成 k5 的方式连接另一个点(我知道使用一种类型的选择,从数学上讲,你不可能超过 14。但是有一些方法围绕这个选择,我已经让它运行到 22-23 而不会阻塞我的浏览器。)
有了新的想法,我开始尝试逐批存储信息。当前的构造图每次看到图时都会遍历并搜索图中的所有 k4。我认为这太过分了,因为 k4 在上一张图中将保持不变,并且只有新的 k4 才能出现在添加新点产生的连接中。如果每次找到之前的 k4 时都存储它们,然后仅在新创建的边界边界中搜索,那么您可以将必须执行的比较次数从 (n 4) 减少到 (n-1 3)。
昨晚我尝试实现这一点,并让它正常工作,没有出现明显的错误。虽然我会在这之后返回并梳理它是否存在任何问题,但新方法使程序速度慢得多。之前,该程序进行所有比较所需的时间仅增加了一倍。现在,它似乎在阶乘时间内上涨。我已经回顾并试图找出任何明显的错误,但我想知道对内存的新依赖是否会导致整个速度变慢。
那么,通过这么长的介绍,我的主要问题是程序的内存和速度在像 Chrome 这样的网络浏览器中是如何相关的?我是否通过将一堆小图保留为 JSON 对象来减慢程序速度?理论上我占用多少内存在速度方面应该不重要吗?我在哪里可以了解更多关于两者之间的联系?有没有一本书可以更好地解释这种事情?
感谢您的任何建议或答案。抱歉这篇文章太长了:我仍然深深地沉浸在这个想法中,很难很快解释它。
编辑: 这是显示每种算法的两个网页, 存储以前的发现: http://zacharymaril.com/thoughts/constructionGraph.html
不存储先前的查找: http://zacharymaril.com/thoughts/Expanding%20Frontier/expandingFrontier.html
它们都可以通过 Chrome 浏览器获得最佳观看效果。这是我用来制作此内容的浏览器,如果您使用 ctrl shift i 打开开发面板并输入“times”,您可以看到迄今为止所有时间的集合。
Lately, I've been playing around with Ramsey's theorem for R(5,5). You can see some examples of previous attempts here: http://zacharymaril.com/thoughts/constructionGraph.html
Essence: find all the k4's in a graph/its complement and then connect another point in such a way that no k5's are formed (I know with one type of choice, mathematically it becomes improbable that you would get past 14. But there are ways around that choice and I've gotten it to run as far as 22-23 without bricking my browser.)
With new ideas, I started playing around with storing information from batch to batch. The current construction graph goes through and searches for all the k4's in a graph every time it sees the graph. I thought this was overkill, since the k4's will stay the same in the previous graph and only new k4's could show up in the connections produced by the addition of the new point. If you store the previous k4's each time you find them and then only search in the frontier boundaries that were newly created, then you reduce the number of comparisons you have to do from (n 4) to (n-1 3).
I took a shot at implementing this last night and got it to work without obvious errors. While I am going to go back after this and comb through it for any problems, the new method makes the program much much slower. Before, the program was only ~doubling in terms of time it took to do all the comparisons. Now, it is going up in what looks to be factorial time. I've gone back through and tried to ferret out any obvious errors, but I am wondering whether the new dependence on memory could have created the whole slow down.
So, with that long intro, my main question is how are the memory and speed of a program related in a web browser like chrome? Am I slowing down the program by keeping a bunch of little graphs around as JSON objects? Should it not matter in theory how much memory I take up in terms of speed? Where can I learn more about the connection between the two? Is there a book that could explain this sort of thing better?
Thank you for any advice or answers. Sorry about the length of this: I am still buried pretty deep in the idea and its hard to explain it shortly.
Edit:
Here are the two webpages that show each algorithm,
With storage of previous finds:
http://zacharymaril.com/thoughts/constructionGraph.html
Without storage of previous find:
http://zacharymaril.com/thoughts/Expanding%20Frontier/expandingFrontier.html
They are both best viewed with Chrome. It is the browser I have been using to make this, and if you open up the dev panel with ctrl shift i and type "times", you can see a collection of all the times so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
程序的内存和速度并不紧密相关。
简单的例子:
的硬盘空间将是
为虚拟硬盘而苦苦挣扎
记忆。这会减慢速度
因为硬盘驱动器显着
比公羊慢。
所有的内存都不会做
同样的事情。它不必转到硬盘驱动器,因此速度会更快。
内存。也显着增加
应用程序的速度。这是
内存缓存如何工作。
使用很少的内存。想一个
尝试计算 PI 的程序。
它永远不会完成,但需要非常
小公羊。
一般来说,您使用的内存越少(减去缓存),速度就越好,因为您遇到其他进程施加的限制的机会就越小。
如果您的程序需要花费大量时间来计算将再次引用的项目。将它们缓存在内存中是有意义的,这样您就不需要重新计算它们。
您可以通过向缓存项目添加超时来混合两者。每次将另一个项目添加到缓存时,您都会检查其中的项目并删除一段时间内未访问过的项目。 “一段时间”由您的需要决定。
Memory and speed of a program are not closely interrelated.
Simple examples:
of hard drive space is going to be
thrashing the hard drive for virtual
memory. This will slow things down
as hard drives are significantly
slower than ram.
of all ram is not going to do the
same thing. It won't have to go to the hard drive so will stay quicker.
ram. It also significantly increases
the speed of an application. This is
how memcache works.
use very little ram. Think of a
program that attempts calculating PI.
It will never finish, but needs very
little ram.
In general, the less ram you use (minus caching) the better for speed because there's less chance you're going to run into constraints imposed by other processes.
If you have a program that takes considerable time to calculate items that are going to be referenced again. It makes sense to cache them memory so you don't need to recalculate them.
You can mix the two by adding timeouts to the cached items. Every time you add another item to the cache, you check the items there and remove any that haven't been accessed in a while. "A while" is determined by your need.