search
HomeBackend DevelopmentPHP TutorialPHP generates millions of UIDs and stores them in files

This is a question asked in a group today. The main reason is that writing files takes a long time.

I am doing an experiment here. Every 20,000 UIDs are written into a file. One file is written approximately 280kb, so the overall writing time is only 13S

Post the code

<code><span><span><?php </span>
set_time_limit(<span>0</span>);

<span>$starttime</span> = time();

<span>$fh</span> = fopen(<span>$filename</span>,<span>'w'</span>);

<span>for</span>(<span>$i</span>=<span>0</span>;<span>$i</span>1000000</span>;<span>$i</span>++)
{
    <span>$uid</span> = uniqid();
    <span>if</span>(<span>$i</span>%<span>20000</span> == <span>0</span>) 
    {
        <span>$filename</span> = <span>$i</span>.<span>'.txt'</span>;

    }
    fwrite(<span>$fh</span>,<span>$uid</span>.<span>' '</span>);
}
<span>$endtime</span> = time();
<span>echo</span><span>'总用时:'</span>.(<span>$endtime</span>-<span>$starttime</span>).<span>'s'</span>;
<span>?></span></span></code>

Copyright statement: This article is a blog This is an original article and may not be reproduced without the permission of the blogger.

The above introduces PHP to generate millions of UIDs and save them in files, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
番茄小说uid在什么地方查看番茄小说uid在什么地方查看Feb 28, 2024 pm 04:25 PM

在使用番茄小说软件时,登录自己的账号这样您可以享受到更多个性化的服务和便利。登录账号后,您还能查看到自己的UID(用户唯一标识符),这是一个非常重要的信息,有时候这个uid是非常重要的,那么在番茄小说中自己的UID究竟在哪里查看呢?想要了解的用户们就快来跟着本文一起详细了解查看步骤吧!番茄小说uid在什么地方查看答案:【番茄小说】-【我的】-【反馈与帮助】-【意见反馈】-【点击5下】。具体步骤:1、首先打开番茄小说软件,进入到首页中后我们需要点击右下角的【我的】;2、然后在我的页面中我们滑动到页

time包的单调时钟处理time包的单调时钟处理Aug 04, 2023 pm 05:45 PM

我们今天主要是来看一看golang time 包的时间应用方式。两者的一般规则是「wall time」用于告知时间,而「monotonic clock」用于测量时间;除外还有其他的时钟处理方式。

一行命令找出 Linux 中所有真实用户一行命令找出 Linux 中所有真实用户Feb 18, 2024 pm 05:50 PM

哈喽大家好,我是咸鱼。接触过Linux的小伙伴们都知道在Linux(或者说类Unix)中,有三种类型的用户:超级用户(UID为0):即root用户,拥有最高权限。系统用户(UID为1~999):系统内建用户,用于运行系统服务和守护进程。普通用户(UID为1000~60000):为了让使用者能够使用Linux系统资源而建立的,用户新建的账号一般就是普通账号。那么现在问题来了,如何快速找出Linux中的真实用户(root用户和普通用户)?正式开始之前,我们先介绍一个工具——getent。getent

深入了解Linux用户UID和GID的查看方式深入了解Linux用户UID和GID的查看方式Mar 20, 2024 pm 12:06 PM

用户UID和GID是Linux系统中用来标识用户和组的数字标识符。在使用Linux系统时,我们经常需要查看用户的UID和GID,以便管理用户和文件的权限。本文将深入介绍Linux系统中查看用户UID和GID的多种方式,并附上具体的代码示例。一、通过命令查看用户UID和GID查看当前用户的UID和GID:id运行以上命令后,系统会显示当前用户的UID、GID以

Java8 Time Api如何使用Java8 Time Api如何使用Apr 28, 2023 pm 12:25 PM

1.概述作为本文的一部分,让我们从现有Date和CalendarAPI存在的一些问题入手,来探讨新的Java8Date和TimeAPI如何解决这些问题。我们还将搞一搞Java8时间类库中的核心类,比如LocalDate,LocalTime,LocalDateTime,ZonedDateTime,Period,Duration以及它们的api。2.旧的时间API(java8之前)的问题线程安全-Date和Calendar类不是线程安全的,使开发者难以调试这些api的并发问题,需要编写额外的代码来处

Python time模块时间怎么获取和转换Python time模块时间怎么获取和转换May 13, 2023 pm 12:19 PM

Pythontime模块时间获取和转换Python的Time库可以进行时间相关的处理,如访问当前日期和时间,输出不同格式的时间以及等待指定的时间等。1.获取时间1.1.时间戳importtimetimestamp=time.time()#1682737552.5009851格林威治时间(GMT)1970年01月01日00时00分00秒起至现在的总秒数1.2.结构化时间importtimestruct_time=time.localtime()#time.struct_time(tm_year=2

Linux命令:查看用户UID和GID的技巧Linux命令:查看用户UID和GID的技巧Mar 20, 2024 pm 12:33 PM

Linux操作系统是一种广泛使用的开源操作系统,它为用户提供了丰富的命令行工具,让用户可以更轻松地管理系统。在Linux系统中,每个用户都有一个唯一的用户标识符(UserID,UID)和一个组标识符(GroupID,GID)。了解用户的UID和GID对于系统管理和文件权限管理非常重要,本文将介绍几种查看用户UID和GID的技巧,以便更好地管理Linux系

python中time和datetime的区别及用法是什么python中time和datetime的区别及用法是什么May 02, 2023 am 11:01 AM

一.Python中表示时间的两种方式:时间戳:相对于1970.1.100:00:00以秒计算的偏移量,唯一的时间元组struct_time:共有9个元素>tm_year:年1-12>tm_mon:月1-12>tm_mday:日1-31>tm_hour:时0-23>tm_min:分0-59>tm_sec:秒0-59>tm_wday:星期0-6(0表示周日)>tm_day:一年中的第几天1-366>tm_isdst:是否是夏令,默认为-1二.ti

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),