PHP函数rand和mt_rand

Posted by & filed under Programming.

mt_rand() 比rand() 快四倍 很多老的 libc 的随机数发生器具有一些不确定和未知的特性而且很慢。PHP 的 rand() 函数默认使用 libc 随机数发生器。mt_rand() 函数是非正式用来替换它的。该函数用了 Mersenne Twister 中已知的特性作为随机数发生器,mt_rand() 可以产生随机数值的平均速度比 libc 提供的 rand() 快四倍。

关于搜索引擎原理

Posted by & filed under Excellence Article.

我知道这个问题很宽泛 … 也知道这不是一两句话能说清的 … 但是我还是想知道搜索引擎获得结果的原理 … 我有无数个爬虫爬下来一千万条也就是 10M 条的文本 … 现在我要从这 10M 条文本里面获得含有特定字符串的内容 … 分词或其他都不考虑 … 就是有 strpos 特定字符串的文本返回 … 搜索引擎是怎么做到的呢 ..? 一般的搜索引擎你输入关键字之后结果非常快就反馈出来了 … 但是在后台它是如何操作的 ..? 因为待搜索的内容是不确定的 … keyword 索引这种方法显然不可行 … 那么遍历存储的每一个文件 …? 这样的效率真的会比 MATCH AGAINST 高么 ..? 另外说哪怕没有任何记录搜索引擎也会很快提示 Not Found … 如果说一次扫过 10M 条记录 … 数据读取速度也和硬盘转速也是瓶颈 … 不可能有这么快的响应 … 或者是 1k 台服务器的集群 … 每台服务器负责搜索… Read more »

Top 10 Concepts That Every Software Engineer Should Know

Posted by & filed under Study & Reading.

he future of software development is about good craftsmen. With infrastructure like Amazon Web Services and an abundance of basic libraries, it no longer takes a village to build a good piece of software. These days, a couple of engineers who know what they are doing can deliver complete systems. In this post, we discuss… Read more »