闽公网安备 35020302035485号
                import http from "node:http";
 http.createServer((req, resp) => {
  try {
   if (req.method !== "GET") {
    return resp.writeHead(405).end();
   }
   if (req.url !== "/") {
    return resp.writeHead(404).end();
   }
   resp.writeHead(200, {
    "content-type": "text/plain",
   });
   resp.end("Hello world");
  } catch (e) {
   resp.writeHead(500).end();
  }
 }).listen(3000);
Spring Boot测试代码:package com.example.demo;
 // 堆代码 duidaima.com
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.Spring BootApplication;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.RestController;
 @Spring BootApplication
 @RestController
 public class DemoApplication {
   public static void main(String[] args) {
     SpringApplication.run(DemoApplication.class, args);
   }
   @GetMapping("/")
   public String handleRequest() {
     return "Hello World!";
   }
 }
测试时,每个并发执行500万请求,对比如下性能指标:4.资源占用情况:CPU和内存平均使用率