当前位置: 首页 > news >正文

asp网站 并发数/网络营销与直播电商就业前景

asp网站 并发数,网络营销与直播电商就业前景,推荐网站网页,网络设计专业究竟好不好就业文章目录 背景常用定时器实现 任务队列时间轮介绍基本结构指针移动定时任务插入循环任务插入代码示例 多层时间轮使用流程 代码 背景 在软件开发中,定时器是一个极为常用的组件,它发挥着至关重要的作用。通过定时器,开发者能够精确地控制程序…

文章目录

  • 背景
    • 常用定时器实现
  • 任务队列
  • 时间轮介绍
    • 基本结构
    • 指针移动
    • 定时任务插入
    • 循环任务插入
    • 代码示例
  • 多层时间轮
    • 使用
    • 流程
  • 代码

背景

在软件开发中,定时器是一个极为常用的组件,它发挥着至关重要的作用。通过定时器,开发者能够精确地控制程序中的时间流程,实现诸如定时任务执行、周期性执行、资源延迟释放、状态定时更新等功能。关于定时器的实现方式,存在多种高效且灵活的途径。

常用定时器实现

  • 操作系统级定时器:利用操作系统提供的定时器API,如Linux下的timer_create、timer_settime等,这些API提供了精确的时间控制和事件通知机制,适合需要高精确度控制的场景。
  • 多线程/多进程定时器:通过创建专门的线程或进程来管理定时器任务,这些线程/进程可以独立运行,使用系统时间或自定义的时间管理逻辑来触发定时事件。这种方式在并发处理上有优势,但需注意线程/进程间的同步与资源竞争问题。
  • 事件循环中的定时器:在基于事件循环的编程模型中(epoll_wait),定时器是事件的一种,通过事件循环机制定期检查并执行。这种方式简化了并发控制,但定时精度可能受到事件循环中其他任务执行时间的影响。
  • 时间轮算法:时间轮是一种高效的时间管理算法,通过将时间划分为多个层级和槽位,以轮转的方式管理定时任务。多层时间轮定时器结合了时间轮的高效性和灵活性,能够处理大量定时任务而不引入显著的性能开销。
  • 定时任务队列:使用优先队列(如最小堆)来管理定时任务,每个任务根据其执行时间排序。当有新任务加入或当前时间推进时,队列会自动调整,确保最早到期的任务始终位于队列前端。这种方法适合需要频繁添加和删除任务的场景。

任务队列

  • 1 启动一个定时器线程,线程中有任务队列。
  • 2 其他线程将所有的定时任务放到队列中并进行排序,每个任务都保存一份自己的定时信息,
  • 3 定时器每隔一个周期轮询一遍队列中的所有任务,如果任务的超时时间已到,则执行该任务,如果超时时间还没到,则将该任务的定时信息减掉一个定时器的时间间隔,等到完全减为0时,该任务就可以被执行了
  • 4 根据优先级不同或者定时任务过多 可以拆分为多个定时器

时间轮介绍

在这里插入图片描述

模拟时钟的运作机制,将时间划分为多个固定的时间间隔(称为槽位),并将定时任务存储在相应槽位中,随着时间的推进,时间轮会周期性地转动,执行到达时间点的任务。

基本结构

  • 槽位(Slots):时间轮上的一系列位置,每个位置代表一个时间间隔。
  • 指针(Pointer):指向当前时间所在槽位的指针。
  • 链表(Lists):每个槽位关联一个链表,用于存储在该时间间隔内需要执行的任务。
  • 时间间隔(Tick):每个槽位代表的时间长度,例如1秒、1分钟等。
    在这里插入图片描述
    在时间轮中,指针的移动和任务的插入方式取决于时间轮的设计和配置

指针移动

在时间轮中,指针通常代表当前的时间点。在每次“tick”(即时间轮的基本时间单位,如1秒)发生时,指针会向前移动一个槽位。因此,如果您的时间轮是以秒为单位设计的,并且每个槽位代表1秒,那么每次时间推进1秒时,指针就会移动到下一个槽位。

定时任务插入

插入一个定时任务时,需要计算该任务应该在哪个槽位被触发。这通常是通过将任务的延迟时间(从当前时间开始计算)除以时间轮的基本时间单位(即tick的长度)来完成的。然后,将结果对时间轮的槽位总数取模,以找到正确的槽位。

示例 1:1秒间隔,5秒后执行的任务
如果时间轮每个槽位代表1秒,并且您想插入一个5秒后执行的任务,可以这样做:

  • 当前时间(指针位置)为 current
  • 延迟时间为 5 秒
  • 计算目标槽位:(current + 5) % WHEEL_SIZE
    然后,将任务插入到计算出的槽位中。如果 current 是 0,并且 WHEEL_SIZE 是 60,那么目标槽位将是 5。

循环任务插入

时间轮本身并不直接支持“周期性任务”,可以通过在任务回调中重新添加任务来实现这一点

  • 首次插入:与上面相同,计算首次执行的槽位,并插入任务。
  • 回调中重新添加:在任务的回调函数中,计算下一次执行的槽位,并再次将任务添加到时间轮中

代码示例

#include <stdio.h>  
#include <stdlib.h>  
#include <stdint.h>  
#include <stdbool.h>  #define WHEEL_SIZE 60 // 假设时间轮有60个槽位,每个槽位代表1秒  // 定时任务结构体  
typedef struct TimerTask {  struct TimerTask *next; // 指向下一个任务的指针  uint32_t expire;        // 任务到期时间(秒)  void (*callback)(void*); // 任务到期时调用的回调函数  void *arg;               // 传递给回调函数的参数  
} TimerTask;  // 时间轮结构体  
typedef struct {  TimerTask *slots[WHEEL_SIZE]; // 槽位数组,每个槽位指向一个链表头  uint32_t current;              // 当前时间(秒),指向当前槽位  uint32_t tick;                 // 每个槽位的时间间隔(秒)  
} TimeWheel;  // 初始化时间轮  
void time_wheel_init(TimeWheel *wheel, uint32_t tick){ int i =0; for (i = 0; i < WHEEL_SIZE; i++) {  wheel->slots[i] = NULL;  }  wheel->current = 0;  wheel->tick = tick;  
}  // 添加定时任务  
void time_wheel_add_task(TimeWheel *wheel, TimerTask *task, uint32_t delay) {  uint32_t target = wheel->current + delay; // 计算目标槽位  target = target % WHEEL_SIZE; // 循环回到起点  // 将任务添加到对应槽位的链表头部  task->next = wheel->slots[target];  wheel->slots[target] = task;  
}  // 模拟时间推进并执行任务(需要外部定时器或线程驱动)  
void time_wheel_tick(TimeWheel *wheel) {  TimerTask *task, *temp;  uint32_t current = wheel->current;  // 遍历当前槽位及其后续槽位(因为可能有之前因为溢出而延迟的任务)  while (wheel->slots[current] != NULL || (current + 1) % WHEEL_SIZE == wheel->current) {  task = wheel->slots[current];  // 清理当前槽位  while (task != NULL) {  temp = task;  task = task->next;  // 如果任务已过期(或恰好到期),则执行  if (temp->expire <= wheel->current) {  temp->callback(temp->arg);  // 实际应用中,可能需要从链表中删除已执行的任务  // 这里为了简化,不进行删除操作  }  }  wheel->slots[current] = NULL; // 清空当前槽位  current = (current + 1) % WHEEL_SIZE; // 移动到下一个槽位  // 如果回到了起点,说明已经遍历完一轮  if (current == wheel->current) {  break;  }  // 更新当前时间  wheel->current = current;  }  
}  // 示例:回调函数  
void example_callback(void *arg) {  printf("Task executed with argument: %s\n", (char*)arg);  
}  int main() {  TimeWheel wheel;  time_wheel_init(&wheel, 1); // 每个槽位代表1秒  // 创建并添加任务(这里只是示例,实际中需要动态分配内存)  TimerTask task1 = {0, 5, example_callback, "Hello"};  TimerTask task2 = {0, 10, example_callback, "World"};  time_wheel_add_task(&wheel, &task1, 5);  time_wheel_add_task(&wheel, &task2, 10);  // 模拟时间推进(这里用循环代替实际的时间推进机制)  for (int i = 0; i < 15; i++) {  time_wheel_tick(&wheel);  printf("Tick %d\n", i + 1);  }  return 0;  
}

多层时间轮

单层时间轮的性能上限很低,一旦精度和时间跨度要求上来,就无法达到期望的目标了
.比如

  • 一个具有10个槽的时间轮,wheel size = 10,每两个槽之间的间隔为1s,这个间隔称为tick,即最小的时间间隔,那么这个时间轮的跨度就是10*1 = 10s,也就是所支持能设置的最大周期为10s,如果一个任务每隔11秒执行一次.就无法使用
  • 内存空间浪费问题:时间尺度密集,任务数量少,大部分时间尺度占用的内存空间没有意义

多层时间轮
在这里插入图片描述

它通过模拟时钟的运作机制,将时间划分为多个层级(如秒、分、时等),并在每个层级上使用一个或多个时间轮来管理定时任务

多层时间轮定时器将时间划分为多个层级,每个层级代表不同的时间单位(如秒、分、时等)。每个层级都有一个时间轮,时间轮上的每个槽位代表一个时间间隔。定时任务根据其超时时间被分配到不同层级的时间轮上,并存储在相应槽位的链表中。随着时间的推移,时间轮转动,当某个槽位的时间到达时,该槽位上的所有定时任务都将被执行。
在这里插入图片描述

使用

  • 秒级时间轮上,设有60个槽, 每两个槽之间的时间为1s.
  • 分钟级时间轮上,设有60s个槽,每两个槽之间的时间为1min
  • 小时级时间轮上,设有24个槽,每两个槽之间的时间为1h.

流程

添加 一个 1分钟 5秒后执行的任务
  • 计算总延迟:首先,计算任务的总延迟时间(以秒为单位),这里是65秒(1分钟 + 5秒)。
  • 确定分层槽位:将总延迟除以分层的时间间隔(60秒),得到分层槽位的索引。对于65秒,这将是 65 / 60 = 1(取整数部分),意味着任务将在分层的第2个槽位触发(索引从0开始)。注意:分层槽位仅代表分钟的开始,并不精确到秒
  • 确定秒层槽位:计算剩余的秒数(65 % 60 = 5),这表示在分层槽位对应的时间点之后,任务还需要在秒层等待5秒才能执行。
  • 添加任务到秒层并分层:
    如果任务仅在当前分钟内执行:可以将任务添加到秒层的第5个槽位(假设时间轮当前指针在0秒位置,并且它会在下一轮中移动到正确的槽位)。但是,由于时间轮是周期性的,如果当前时间接近分钟结束,您可能需要将任务添加到下一轮的秒层中,并设置标记来指示它应该在上一个分层的下一个周期执行。

代码

#include <memory>
#include <list>
#include <vector>
#include <mutex>typedef struct TimePos{int pos_ms;int pos_sec;int pos_min;
}TimePos_t;typedef struct Event {int id;void(*cb)(void);void* arg;TimePos_t timePos;int interval;
}Event_t;class TimeWheel {typedef std::shared_ptr<TimeWheel> TimeWheelPtr;typedef void (*EventCallback_t)(void );typedef std::vector<std::list<Event_t>> EventSlotList_t;
public:TimeWheel();void initTimeWheel(int steps, int maxMin);void createTimingEvent(int interval, EventCallback_t callback);public:static void* loopForInterval(void* arg);private:int getCurrentMs(TimePos_t timePos);int createEventId();int processEvent(std::list<Event_t> &eventList);void getTriggerTimeFromInterval(int interval, TimePos_t &timePos);void insertEventToSlot(int interval, Event_t& event);EventSlotList_t m_eventSlotList;TimePos_t m_timePos;pthread_t m_loopThread;int m_firstLevelCount;int m_secondLevelCount;int m_thirdLevelCount; int m_steps;int m_increaseId;  // not usedstd::mutex m_mutex;
};
TimeWheel.cpp#include "TimeWheel.h"#include <iostream>
#include <memory.h>
#include <chrono>
#include <thread>TimeWheel::TimeWheel() : m_steps(0), m_firstLevelCount(0), m_secondLevelCount(60), m_thirdLevelCount(0),m_increaseId (0){memset(&m_timePos, 0, sizeof(m_timePos));}void* TimeWheel::loopForInterval(void* arg)
{if(arg == NULL) {printf("valid parameter\n");return NULL;}TimeWheel* timeWheel = reinterpret_cast<TimeWheel*>(arg);while(1) {std::this_thread::sleep_for(std::chrono::milliseconds(timeWheel->m_steps));// printf("wake up\n");TimePos pos = {0};TimePos m_lastTimePos = timeWheel->m_timePos;//update slot of current TimeWheeltimeWheel->getTriggerTimeFromInterval(timeWheel->m_steps, pos);timeWheel->m_timePos = pos;{std::unique_lock<std::mutex> lock(timeWheel->m_mutex);// if minute changed, process in integral point (minute)if (pos.pos_min != m_lastTimePos.pos_min){// printf("minutes changed\n");std::list<Event_t>* eventList = &timeWheel->m_eventSlotList[timeWheel->m_timePos.pos_min + timeWheel->m_firstLevelCount + timeWheel->m_secondLevelCount];timeWheel->processEvent(*eventList);eventList->clear();}else if (pos.pos_sec != m_lastTimePos.pos_sec){//in same minute, but second changed, now is in this integral second// printf("second changed\n");std::list<Event_t>* eventList = &timeWheel->m_eventSlotList[timeWheel->m_timePos.pos_sec + timeWheel->m_firstLevelCount];timeWheel->processEvent(*eventList);eventList->clear();}else if (pos.pos_ms != m_lastTimePos.pos_ms){//now in this ms// printf("ms changed\n");std::list<Event_t>* eventList = &timeWheel->m_eventSlotList[timeWheel->m_timePos.pos_ms];timeWheel->processEvent(*eventList);eventList->clear();}// printf("loop over\n");}}return nullptr;
}//init TimeWheel's step and maxmin, which detemine the max period of this wheel
void TimeWheel::initTimeWheel(int steps, int maxMin)
{if (1000 % steps != 0){printf("invalid steps\n");return;}m_steps = steps;m_firstLevelCount = 1000/steps;m_thirdLevelCount = maxMin;m_eventSlotList.resize(m_firstLevelCount + m_secondLevelCount + m_thirdLevelCount);int ret = pthread_create(&m_loopThread, NULL, loopForInterval, this);if(ret != 0) {printf("create thread error:%s\n", strerror(errno));return;}// pthread_join(m_loopThread, NULL);
}void TimeWheel::createTimingEvent(int interval, EventCallback_t callback){if(interval < m_steps || interval % m_steps != 0 || interval >= m_steps*m_firstLevelCount*m_secondLevelCount*m_thirdLevelCount){printf("invalid interval\n");return;}printf("start create event\n");Event_t event = {0};event.interval = interval;event.cb = callback;//set time startevent.timePos.pos_min = m_timePos.pos_min;event.timePos.pos_sec = m_timePos.pos_sec;event.timePos.pos_ms = m_timePos.pos_ms;event.id = createEventId();// insert it to a slot of TimeWheelstd::unique_lock<std::mutex> lock(m_mutex);insertEventToSlot(interval, event);printf("create over\n");
}int TimeWheel::createEventId() {return m_increaseId++;  
}void TimeWheel::getTriggerTimeFromInterval(int interval, TimePos_t &timePos) {//get current time: msint curTime = getCurrentMs(m_timePos);// printf("interval = %d,current ms = %d\n", interval, curTime);//caculate which slot this interval should belong to int futureTime = curTime + interval;// printf("future ms = %d\n", futureTime);timePos.pos_min =  (futureTime/1000/60)%m_thirdLevelCount;timePos.pos_sec =  (futureTime%(1000*60))/1000;timePos.pos_ms = (futureTime%1000)/m_steps;// printf("next minPos=%d, secPos=%d, msPos=%d\n", timePos.pos_min, timePos.pos_sec, timePos.pos_ms);return;
}int TimeWheel::getCurrentMs(TimePos_t timePos) {return m_steps * timePos.pos_ms + timePos.pos_sec*1000 +  timePos.pos_min*60*1000;
}int TimeWheel::processEvent(std::list<Event_t> &eventList){// printf("eventList.size=%d\n", eventList.size());//process the event for current slotfor(auto event = eventList.begin(); event != eventList.end(); event ++) {//caculate the current msint currentMs = getCurrentMs(m_timePos);//caculate last  time(ms) this event was processedint lastProcessedMs = getCurrentMs(event->timePos);//caculate the distance between now and last time(ms)int distanceMs = (currentMs - lastProcessedMs + (m_secondLevelCount+1)*60*1000)%((m_secondLevelCount+1)*60*1000);//if interval == distanceMs, need process this eventif (event->interval == distanceMs){//process eventevent->cb();//get now pos as this event's start pointevent->timePos = m_timePos;//add this event to slotinsertEventToSlot(event->interval, *event);}else{//this condition will be trigger when process the integral point printf("event->interval != distanceMs\n");// although this event in this positon, but it not arriving timing, it will continue move to next slot caculate by distance ms.insertEventToSlot(distanceMs, *event);}}return 0;
}void TimeWheel::insertEventToSlot(int interval, Event_t& event)
{printf("insertEventToSlot\n");TimePos_t timePos = {0};//caculate the which slot this event should be set togetTriggerTimeFromInterval(interval, timePos);{// printf("timePos.pos_min=%d, m_timePos.pos_min=%d\n", timePos.pos_min, m_timePos.pos_min);// printf("timePos.pos_sec=%d, m_timePos.pos_sec=%d\n", timePos.pos_sec, m_timePos.pos_sec);// printf("timePos.pos_ms=%d, m_timePos.pos_ms=%d\n", timePos.pos_ms, m_timePos.pos_ms);// if minutes not equal to current minute, first insert it to it's minute slotif (timePos.pos_min != m_timePos.pos_min){printf("insert to %d minute\n", m_firstLevelCount + m_secondLevelCount + timePos.pos_min);m_eventSlotList[m_firstLevelCount + m_secondLevelCount + timePos.pos_min].push_back(event);}// if minutes is equal, but second changed, insert slot to this  integral point secondelse if (timePos.pos_sec != m_timePos.pos_sec){printf("insert to %d sec\n",m_firstLevelCount + timePos.pos_sec);m_eventSlotList[m_firstLevelCount + timePos.pos_sec].push_back(event);}//if minute and second is equal, mean this event will not be trigger in integral point, set it to ms slotelse if (timePos.pos_ms != m_timePos.pos_ms){printf("insert to %d ms\n", timePos.pos_ms);m_eventSlotList[timePos.pos_ms].push_back(event);}}return;
}

测试


#include <iostream>
#include "TimeWheel.h"
using namespace std;void funccc(void) {cout << "exec function" << endl;
}int main()
{TimeWheel wheel;wheel.initTimeWheel(100, 10);wheel.createTimingEvent(200, funccc);while (1){}
}

相关文章:

多层时间轮原理以及使用

文章目录 背景常用定时器实现 任务队列时间轮介绍基本结构指针移动定时任务插入循环任务插入代码示例 多层时间轮使用流程 代码 背景 在软件开发中&#xff0c;定时器是一个极为常用的组件&#xff0c;它发挥着至关重要的作用。通过定时器&#xff0c;开发者能够精确地控制程序…...

鸿蒙HarmonyOS开发生态

1、官网 华为开发者联盟-HarmonyOS开发者官网&#xff0c;共建鸿蒙生态 2、开发工具IDE下载及使用 https://developer.huawei.com/consumer/cn/ 3、使用帮助文档 4、发布到华为应用商店 文档中心...

vue中使用jsencrypt加密

vue中封装并使用jsencrypt加密 一般在项目搭建过程中用户注册、登录、修改密码、重置密码等功能都需要用到密码加密的功能&#xff0c;所以把jsencrypt进行封装使用&#xff0c;使代码更加简洁&#xff0c;流程如下&#xff1a; 1、安装jsencrypt npm install jsencrypt2、在…...

SpirngBoot核心思想之一AOP

简介&#xff1a; AOP&#xff08;Aspect-Oriented Programming&#xff0c;面向切面编程&#xff09; 是一种用于解决软件系统中横切关注点的编程范式。在企业级开发中&#xff0c;很多非业务功能&#xff08;如日志、事务、权限、安全等&#xff09;需要在多个模块中执行&am…...

足球预测推荐软件:百万数据阐述百年足球历史-大数据模型量化球员成就值

我开始创建这个模型是从梅西22世界杯夺冠第二天开始准备的&#xff0c;当时互联网上充斥了太多了个人情感的输出&#xff0c;有的人借题对C罗冷嘲热讽&#xff0c;有的人质疑梅西的阿根廷被安排夺冠不配超越马拉多纳做GOAT。作为一个从2002年开始看球的球迷&#xff0c;说实话有…...

AD中如何批量修改丝印的大小,节省layout时间

先选中一个元器件的丝印&#xff0c;然后右键&#xff0c;选择“查找相似项” 直接点击OK&#xff0c;这时会发现所有的丝印都会被选中 然后点击右上角的按键&#xff0c;修改其属性。...

Ps:堆栈

将多张类似的图像图层堆叠在一起形成图像堆栈 Stack&#xff0c;通过应用不同的堆栈模式&#xff0c;可以从这些图像中提取有用的信息或达到特定的视觉效果。 Photoshop 中的堆栈技术被广泛应用于摄影后期处理、科学研究、环境监测与分析等领域。 例如&#xff0c;它常用于减少…...

獨立IP和共用IP有什麼區別?

什麼是獨立IP&#xff1f; 獨立IP指的是一個IP地址專屬於一個用戶或設備。無論是網站、伺服器還是其他線上服務&#xff0c;獨立IP都意味著該IP地址不會與其他用戶或設備共用。獨立IP通常用於需要高安全性和穩定性的場景&#xff0c;比如企業網站、電子商務平臺和需要SSL證書的…...

枢纽云EKP数字门户模板上线!轻松复刻胖东来官网,实现数字化逆袭

数字化转型的浪潮中&#xff0c;胖东来凭借着其独特的企业文化和对员工福利的重视&#xff0c;走进了大众视野。近期&#xff0c;胖东来推出了“不开心假”等员工关怀&#xff0c;又一次引发了大众的广泛关注。这种关怀不仅仅提升了员工的幸福感&#xff0c;也间接的改善了顾客…...

从自动化到智能化:AI如何推动业务流程自动化

引言&#xff1a;从自动化到智能化的必然趋势 在当今数字化时代&#xff0c;企业为了提升效率、降低成本&#xff0c;纷纷采用自动化技术来简化重复性任务。然而&#xff0c;传统自动化仅限于标准化操作&#xff0c;无法应对复杂的决策和多变的市场环境。随着人工智能&#xff…...

Selenium与数据库结合:数据爬取与存储的技术实践

目录 一、Selenium与数据库结合的基础概念 1.1 Selenium简介 1.2 数据库简介 1.3 Selenium与数据库结合的优势 二、Selenium爬取数据的基本步骤 2.1 环境准备 2.2 编写爬虫代码 2.3 数据提取 2.4 异常处理 三、数据存储到数据库 3.1 数据库连接 3.2 数据存储 3.3 …...

在 Docker 中进入 Redis 容器后,可以通过以下方法查看 Redis 版本:

文章目录 1、info server2、redis-cli -v 1、info server [rootlocalhost ~]# docker exec -it spzx-redis redis-cli 127.0.0.1:6379> auth 123456 OK 127.0.0.1:6379> info server # Server redis_version:6.2.6 redis_git_sha1:00000000 redis_git_dirty:0 redis_bui…...

Windows 10 系统安装 FFmpeg 查看、转换、编辑音频文件

1、FFmpeg官网&#xff1a;FFmpeg 点击下载 可以选择下载full版本 下载之后解压到指定目录&#xff0c;在系统环境变量 Path 里面新增环境变量 打开CMD终端运行 ffmpeg -version 查看是否安装成功。 2、基本命令 查看音频基本信息 ffprobe 1.mp3 ##输出 [mp3 000002ab334405…...

反调试防护-API

IsDebuggerPresent() CheckRemoteDebuggerPresent() 其内部实际调用NtQueryInformationProcess() bool _stdcall ThreadCall() {while (true){BOOL pbDebuggerPresent FALSE;CheckRemoteDebuggerPresent(GetCurrentProcess(), &pbDebuggerPresent);if (pbDebuggerPres…...

【视频讲解】非参数重采样bootstrap逻辑回归Logistic应用及模型差异Python实现

全文链接&#xff1a;https://tecdat.cn/?p37759 分析师&#xff1a;Anting Li 本文将深入探讨逻辑回归在心脏病预测中的应用与优化。通过对加州大学欧文分校提供的心脏病数据集进行分析&#xff0c;我们将揭示逻辑回归模型的原理、实现过程以及其在实际应用中的优势和不足…...

Linux系统中命令wc

wc&#xff08;word count&#xff09;命令是Linux和Unix系统中用于计算字数的一个非常实用的工具。它可以统计文件的字节数、字数、行数等信息。默认情况下&#xff0c;wc命令会输出这三个统计值&#xff0c;但你也可以通过选项来指定只输出其中的某些值。 基本用法 wc [选项…...

redis集群部署

创建ConfigMap redis-cm.yaml apiVersion: v1 kind: ConfigMap metadata:name: redis-cluster data:update-node.sh: |#!/bin/shREDIS_NODES"/data/nodes.conf"sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/&quo…...

VUE条件树查询

看如下图所示的功能&#xff0c;是不是可高级了&#xff1f;什么&#xff0c;你没看懂&#xff1f;拜托双击放大看&#xff01; 是的&#xff0c;我最近消失了一段时间就是在研究这个玩意的实现&#xff0c;通过不懈努力与钻研并参考其他人员实现并加以改造&#xff0c;很好&am…...

vue框架学习 -- 日历控件 FullCalendar 使用总结

最近在项目中要实现日期排班的功能&#xff0c;正好要用到日历视图的控件&#xff0c;经过对比发现&#xff0c;vue 中 使用 FullCalendar 可以实现相关需求&#xff0c;下面对使用过程做一个总结。 一. 引入 FullCalendar 控件 package.json 中添加相关依赖 "dependen…...

[数据集][目标检测]猪数据集VOC-2856张

数据集格式&#xff1a;Pascal VOC格式(不包含分割的txt文件&#xff0c;仅仅包含jpg图片和对应的xml) 图片数量(jpg文件个数)&#xff1a;2856 标注数量(xml文件个数)&#xff1a;2856 标注类别数&#xff1a;1 标注类别名称:["pig"] 每个类别标注的框数&#xff1a…...

工业制造场景中的设备管理深度解析

在工业制造的广阔领域中&#xff0c;设备管理涵盖多个关键方面&#xff0c;对企业的高效生产和稳定运营起着举足轻重的作用。 一、设备运行管理 1.设备状态监测 实时监控设备的运行状态是确保生产顺利进行的重要环节。通过传感器和数据采集系统等先进技术&#xff0c;获取设备…...

OpenCV图像文件读写(3)统计多页图像文件中的页面数量函数imcount()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 返回给定文件中的图像数量。 imcount 函数将返回多页图像中的页面数量&#xff0c;对于单页图像则返回 1。 函数原型 size_t cv::imcount (cons…...

【数据治理-构建数据标准体系】

构建数据标准体系分为六大主要步骤&#xff0c;分别是&#xff1a; 1、规划数据标准 2、开发数据标准 3、发布数据标准 4、执行数据标准 5、数据标准遵从检查 6、维护数据标准 1、规划数据标准 &#xff08;1&#xff09;数据标准的规划首先是在公司业务架构和数据架构的范围…...

AI新方向:OpenAI o1是一个更擅长思考的模型系列:高级推理+逻辑严密+更广泛的知识,用于解决复杂的逻辑问题,慢思考

之前推出AI store感觉偏应用&#xff0c;也千篇一律&#xff0c;是AI的一个方向&#xff1a;广度。 现在推出o1 更严密的逻辑&#xff0c;也是AI的一个方向&#xff1a;深度。花更多时间&#xff0c;推理复杂的任务并解决比以前的科学、编码和数学模型更难的问题。确保AI的使用…...

Laravel部署后,CPU 使用率过高

我在部署 Laravel 应用程序时遇到严重问题。当访问量稍微大一点的时候&#xff0c;cpu马上就到100%了&#xff0c; 找了一大堆文档和说明&#xff0c;都是说明laravel处理并发的能力太弱&#xff0c;还不如原生的php。最后找到swoole解决问题。 1、php下载swoole插件&#xff0…...

Rust调用tree-sitter支持自定义语言解析

要使用 Rust 调用 tree-sitter 解析自定义语言&#xff0c;你需要遵循一系列步骤来定义语言的语法&#xff0c;生成解析器&#xff0c;并在 Rust 中使用这个解析器。下面是详细步骤&#xff1a; 1. 定义自定义语言的语法 首先&#xff0c;你需要创建一个 tree-sitter 语言定义…...

如何解决跨域请求中的 CORS 错误

聚沙成塔每天进步一点点 本文回顾 ⭐ 专栏简介如何解决跨域请求中的 CORS 错误1. 引言2. 什么是 CORS&#xff1f;2.1 同源策略示例&#xff1a; 2.2 CORS 请求的类型 3. CORS 错误的原因3.1 常见 CORS 错误示例 4. 解决 CORS 错误的常见方法4.1 在服务器端启用 CORS4.1.1 Node…...

计算机知识科普问答--20(96-100)

文章目录 96、为什么要进行内存管理?1. **多进程环境中的内存共享与隔离**举例:2. **提高内存利用率**举例:3. **虚拟内存支持**举例:4. **内存分配的灵活性与效率**举例:5. **内存保护**举例:6. **内存分段和分页的管理**7. **内存交换(Swapping)**举例:8. **提升系统…...

济南站活动回顾|IvorySQL中的Oracle XML函数使用示例及技术实现原理

近日&#xff0c;由中国开源软件推进联盟PG分会 & 齐鲁软件园联合发起的“PostgreSQL技术峰会济南站”在齐鲁开源社举办。瀚高股份IvorySQL作为合作伙伴受邀参加此次活动。 瀚高股份IvorySQL技术工程师 向逍 带来「IvorySQL中的Oracle XML函数兼容」的议题分享。在演讲中&a…...

【电商搜索】现代工业级电商搜索技术-Facebook语义搜索技术QueSearch

【电商搜索】现代工业级电商搜索技术-Facebook语义搜索技术Que2Search 目录 文章目录 【电商搜索】现代工业级电商搜索技术-Facebook语义搜索技术Que2Search目录0. 论文信息1. 研究背景&#xff1a;2. 技术背景和发展历史&#xff1a;3. 算法建模3.1 模型架构3.1.1 双塔与分类 …...