Replies: 8 comments 3 replies
-
Hey, unfortunately there is nothing recent. I would like to put together a repository with some realistic comparisons but I haven't had the time. Phlex is faster than ActionView mainly because it uses a faster buffer (a raw string) and it doesn't need to do any inflection to look up partials, since they’re constants. Once the compiler is finished (based on my initial benchmarks), Phlex performance should be about the same as compiled HAML but that's still a while off. |
Beta Was this translation helpful? Give feedback.
-
So after making this pull request #481 I wanted to see how Phlex would perform in a super basic Hanami app (I was just starting to explore newly minted Hanami 2) Honestly, I'm a bit blown away. All I'm doing in my Hanami Action (think Rails Controller method/action)
In my template I'm iterating over the request hash object and simply building an HTML table, with randomly generated color for background JSON response is about 1.15x slower than Phlex response 🚀 🤯 🤯 🤯 🚀 😄 |
Beta Was this translation helpful? Give feedback.
-
Set it up in a repo, and reran results, similar to what I mentioned above, although a bit slower, as my computer went into "take off mode" as fans, started running like crazy. Check out the results here: https://github.com/konung/hanami-phlex-test-idea |
Beta Was this translation helpful? Give feedback.
-
Hey 👋 Thanks for doing all these benchmarks! Phlex is definitely slower than pure compiled templating languages like Slim, ERB and HAML. But view frameworks like ActionView and ViewComponent add a lot of overhead beyond just rendering the template and that's where Phlex pulls ahead, as you've seen from the Hanami benchmarks. I’m really happy with the performance so far but I’m also working on a compiler for Phlex that will make the template rendering significantly faster (like 10 - 100x) faster. https://github.com/joeldrapper/phlex-compiler I’ve had to take a break from this to focus on other things but I’m really excited to get back to it. |
Beta Was this translation helpful? Give feedback.
-
Here are the results of running this on Ruby 3.2.1 with YJIT on my M1 MacBook Pro with 16GBs of RAM. Phlex got over 10k IPS.
|
Beta Was this translation helpful? Give feedback.
-
I just discovered Phlex recently, and it really excites me. I recently started using ViewComponent, but always felt like it wasn't quite what I wanted. Phlex seems to answer everything perfectly. Are there any benchmarks comparing it to ViewComponent and ERB + Helpers? That's what I'd be most interested in for a benchmark |
Beta Was this translation helpful? Give feedback.
-
I agree Phlex could replace both Cells+Haml/Erb/Slim or ViewComponent + /Erb/Slim/Haml combinations. As far as in the context of Rails + ActionView / View Component + Template - my gut feeling says that Phlex will be way faster than those combinations. Even before it's compiles as @joeldrapper mentions. Simply because there are less layers, less orchestrations, and no template parsing. I haven't tried running Phlex in Rails context yet, but may try once I revisit this for Hanami On a side note: I've tried ViewComponent. But can't get fully behind it . To mee it's seems like a more complicated version of Cells. I think Cells just "clicks" better for me, or maybe because I've been using them for so long. And Phlex in my subjective view is closer to Cells, than ViewComponent the way you use it. |
Beta Was this translation helpful? Give feedback.
-
Is Hanami::View going to be using Phlex? I agree it seems logical that it would be much faster than ViewComponent + ERB. I might take a stab at making some benchmarks. I'm constantly starting new Rails projects so it would be super helpful for me to have some data before I make Phlex my go-to. I'm also very curious about benchmarking a view that's 100% Phlex (like from the application layout down to each component) vs a standard Rails ERB layout/page with some Phlex components in it. I don't have any experience with Cells but it does look nice. I chose ViewComponent because they talk explicitly about performance. I'm always looking for gems like this that can make big improvements with minimal effort on my end. I also love that Phlex makes single-file components so easy. I know it's possible with ViewComponent, but then I'd have to use Rails' tag helpers, which I don't think are very performant |
Beta Was this translation helpful? Give feedback.
-
Hi
Just discovered Phlex through Ruby Weekly :D
It looks very interesting and reminds me a lot of (LuckyFramework)[https://luckyframework.org/guides/frontend/rendering-html] in Crystal. 👍 and papercraft gem.
I was just wondering if there is a speed/performance comparison against Slim, Haml, Erb? I personally use Hamlit in my Ruby projects, which is an optimized version of Haml, a) I like Haml's syntax over ERB, b) Performance used to be significantly better over other engines, but now they are getting closer (latest versions of Hamlit, Haml & ERB are in the same ballpark, based Hamlit's benchmark (https://github.com/k0kubun/hamlit/tree/master/benchmark)
I didn't find anything through Google search or issues/repo here. Very possible, I'm just being blind 😄
Any pointers to any such comparisons, or benchmarks, would be appreciated.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions