时间:2025-03-13 20:21
人气:
作者:admin
今天无聊又翻出了一篇很久以前golang和.net测试的文章(原文),
很是好奇7、8年过去了,golang和.net 有啥变化吗?
于是我在电脑上又测了一遍。
我的电脑是win10系统,.net sdk都下了最新的版本,重新安装了一编,golang用的是go1.24.1。
添加了rust 的actix-web和may_minihttp。为啥是may_minihttp?因为在techempower第23轮测试中may_minihttp排第一。

好了,各位大佬来看看测试结果吧



5000000 个请求的时间 - 越短越好。
using Microsoft.AspNetCore.Mvc;
namespace _5.Controllers
{
// ValuesController is the equivalent
// `ValuesController` of the Iris 8.3 mvc application.
[Route("api/[controller]")]
public class ValuesController : ControllerBase
{
// Get handles "GET" requests to "api/values/{id}".
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// Put handles "PUT" requests to "api/values/{id}".
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// Delete handles "DELETE" requests to "api/values/{id}".
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}
app.MapGet("/api/values/{id}", (int id) =>
{
return "value";
})
.WithName("GetApi")
.WithOpenApi();
package main
import (
"github.com/gin-gonic/gin"
"io/ioutil"
)
func main() {
gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = ioutil.Discard
r := gin.Default()
r.GET("/api/values/:id", func(c *gin.Context) {
c.String(200, "value")
})
r.Run() // 监听并在 0.0.0.0:8080 上启动服务
}
package main
import "github.com/kataras/iris/v12"
func main() {
app := iris.New()
booksAPI := app.Party("/api")
{
booksAPI.Use(iris.Compression)
booksAPI.Get("/values/{id}", Get)
}
app.Listen(":8080")
}
func Get(ctx iris.Context) {
// id,_ := vc.Params.GetInt("id")
ctx.WriteString("value")
}
use std::io;
use may_minihttp::{HttpServer, HttpService, Request, Response};
use may::coroutine;
#[derive(Clone)]
struct HelloWorld;
impl HttpService for HelloWorld {
fn call(&mut self, _req: Request, res: &mut Response) -> io::Result<()> {
match _req.path() {
"/api/values" => {
res.body("Hello, world!");
}
_ => {
res.status_code(404, "Not Found");
}
}
Ok(())
}
}
// 在 `main` 函数中启动服务器。
fn main() {
// 配置 may 协程池
may::config()
.set_workers(8) // 设置线程数
.set_pool_capacity(500) // 设置协程池容量
.set_stack_size(0x1000); // 设置协程栈大小
let server = HttpServer(HelloWorld).start("0.0.0.0:8080").unwrap();
println!("Server running at http://127.0.0.1:8080");
server.join().unwrap();
}
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
async fn greet(req: HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap_or("World");
format!("Hello {}!", &name)
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(greet))
.route("/api/values/{name}", web::get().to(greet))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
CPU:7840H
内存:32.0 GB
网卡:AX210
操作系统: Windows 10 22H2 专业版
https://linux.cn/article-8935-1-rel.html
https://hackernoon.com/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8
Microsoft Agent Framework Skills 执行 Scripts(实
EF Core 原生 SQL 实战:FromSql、SqlQuery 与对