TechEmpower Web 框架性能测试结果正式发布

TechEmpower的Web框架性能测试结果显示,C++的Lithium以其出色的ORM性能脱颖而出,超越Rust的Diesel。PHP的Workerman异军突起,Ubiquity框架凭借其性能夺得高排名。Ruby的Roda在不完全使用异步架构的情况下展现出强大潜力。这次测试揭示了不同语言框架在性能上的显著差异。
摘要由CSDN通过智能技术生成

TechEmpower Framework Benchmarks

基于TechEmpower的《Web Framework Benchmarks》性能基准测试的解读之后

 注:带星号的项目支持完整的ORM和模板技术

一、神奇的Lithium

C++和Rust都是只提供编译期反射的,所以实现ORM的方法有两种,一种是带生成器,需要工具和预处理。一种是利用宏和模板技术来生成代码。

Lithium这个项目和其它妖艳贱货不一样,代码优雅得一塌糊涂,而且性能惊人Lithium(ORM)(RAW)以 59.2%的成绩一骑绝尘。虽然使用宏和模板有点烧脑,但还是值得一看。

对比Rust的Diesel,仅取得了24%的成绩还是有很大提升空间的。Golang的框架测试代码中没有一个带ORM,是因为Golang的反射机制还是很慢的,直接拖累了性能。

  auto fortunes = sql_orm_schema(sql_db, "Fortune").fields(
    s::id(s::auto_increment, s::primary_key) = int(),
    s::message = std::string());

  my_api.get("/fortunes") = [&](http_request& request, http_response& response) {
    sql_db.max_async_connections_per_thread_ = fortunes_nconn;

    typedef decltype(fortunes.all_fields()) fortune;
    std::vector<fortune> table;

    {
      auto c = fortunes.connect(request.fiber);
      c.forall([&] (const auto& f) { table.emplace_back(metamap_clone(f)); });
    }
    table.emplace_back(0, "Additional fortune added at request time.");

    std::sort(table.begin(), table.end(),
              [] (const fortune& a, const fortune& b) { return a.message < b.message; });

    li::growing_output_buffer ss;
 
    ss << "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>";
    for(auto& f : table)
    {
      ss << "<tr><td>" << f.id << "</td><td>";
      escape_html_entities(ss, f.message); 
      ss << "</td&g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值