Skip to content

Conversation

phpfui
Copy link

@phpfui phpfui commented Feb 23, 2024

I added my ORM, phpfui/orm. I was quite impressed with the performance. I believe the logic is correct. I patterned off the Eloquent source.

Also updated to more modern PHP. Eloquent is now the latest. I removed the vendor files, which should never be checked in.

The other ORMs don't seem to work. I would update them to the latest, but not sure how they all work. Probably not that difficult, just no idea of how to fix them.

@adrianmiu
Copy link
Owner

@phpfui Sorry for the delayed response. I've checked your code and I've found the following:

  1. On the first run I got zero memory usage which made me investigate the tests
  2. The insert() method doesn't seem to actually insert the record into the DB. I've added things like $product->insert() and $category->insert() and the time went from 22ms to 36ms and memory usages at around 8Mb
  3. The eager loading test is empty. It is supposed to time the retrieval of products with related objects.

@phpfui
Copy link
Author

phpfui commented Jun 10, 2024

I'll revisit. I am not sure I fully implemented things correctly for the benchmarks. I may have questions and will let you know.

Thanks for the followup.

@phpfui
Copy link
Author

phpfui commented Jun 20, 2024

Yes, the insert was missing. Fixed.

I had also update the eager loading test before, but forgot to push it. Should be OK now.

The reason the memory usage is zero or near zero is because PHPFUI/ORM is not a repository model with collections of records. It is an Active Record / Active Table model with Cursors to minimize memory usage, which is the bane of ORMs in general and why I decided to write an ORM. It will map very closely to raw SQL because it generates raw SQL from an interface that models SQL itself. This is not an abstract ORM that can use any database structure, it can only be used on an SQL schema, like 99% of all apps use, so there was no need to slow it down making it generic to any DB schema.

I also noticed it seems that all tests are using SQLite memory. I think you intended to test both disk and memory. Not sure if I broke that (don't think so), but worth looking into.

I also updated some of the dependencies, but several ORMs seem to be broken when I tried them. Missing classes or PHP errors. I commented them out of the main test file. I would fix these, but no idea how and it seems many are no longer supported anyway.

Let me know of any questions / issues you have.

Thanks for posting and maintaining an ORM benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants