123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|371|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> CodeIgniter / Stealth's Framework

Sat, 14 Jan 2012, 03:29
Stealth
Stop sucking so much CodeIgniter. You're fucking up my chart:



(Disclaimer: This is just measuring resource usage of fresh installs.)

|edit| Added simpler single chart. |edit|

-=-=-
Quit posting and try Google.
Sat, 14 Jan 2012, 03:29
JL235
CI does a lot of auto loading, of things you'll actually use, and so this is less of an issue on any real site
Sat, 14 Jan 2012, 04:13
Stealth
I've written plenty of production applications in Frequency DVT. Just running some tests now shows that my store application is served in 138ms. A fresh install of CodeIgniter takes 103ms to serve. It also does it in less memory. Remember that this is a real application doing database queries and rendering multiple views. It's extremely efficient because that was the goal from day one. It's been an obsession of mine. The framework determines the request and immediately calls the controller. If you need resources, it loads them as needed. The new version uses static calls more prevalently to avoid instantiating so much (=memory). I also reduced the loader down to 100 lines of code while making it more powerful (it was 500).

I believe there is a deeper problem with CodeIgniter. It's very poorly designed. Binding functionality to $this wastes time and resources. Loaded objects can't be freed up because the framework doesn't know where they are being used. Frequency uses local variables in methods so that they can be garbage collected once the method returns. CodeIgniter also uses a complex file structure. These files do get cached by linux, but it's a waste of memory each time the page is rendered. I could go on forever but I wont.

I just want to make it clear that this is more than magic voodoo. It's a year's worth of obsession. You know it is because I drive you crazy talking about it

-=-=-
Quit posting and try Google.
Sat, 14 Jan 2012, 14:32
HoboBen
What are the units on the graph?

As it looks now, CodeIgniter has lots and lots of speed. About 250 speed, actually. Which sounds great! Frequency doesn't even have 5 speed. On the bright side, it only uses about 50 memories.

-=-=-
blog | work | code | more code
Sat, 14 Jan 2012, 14:50
Stealth
Here are the actual values:

Frequency Prototype: 0.63 kb / 0.55 ms
Frequency DVT: 50.2 kb / 4.07 ms
CodeIgniter 2.1.0: 1313.1 kb / 129.2 ms

(max memory usage - PHP overhead / execution time)

-=-=-
Quit posting and try Google.
Mon, 16 Jan 2012, 02:59
Stealth
I'm highjacking this thread to get some feedback on my framework (the title sounds awful now). Frequency "Prototype" contains a new URL parser to try and eliminate the need for so much routing.

The controller structure is based on nested files and folders:

/controllers/users.php
/controllers/users/edit.php

Each file contains a class with the same name as the file. You can override classes by creating a folder with the same name (you'll see what overriding is in a minute).

The location of the class, methods, parameters all are factored in to how the URL is formed. An example:

/controllers/users.php


The profile() method can be called at:

/users/profile/123

Since it contains an optional parameter, it's also accessible at:

/users/profile/

You can set an index method:

/controllers/users.php


It's not necessary to specify "index" in the URL. This is accessible at both:

/users/
/users/123

We can add another method to our class:

/controllers/users.php


Loaded at:

/users/edit/1

Notice how this parameter is required? We'll call the index method if we try to load:

/users/edit

The framework decides that since you didn't pass the right number of parameters, you probably want to call index() and pass "edit". If we set the parameter on edit to be optional, edit() would take priority over index().

So what about those controllers nested in folders? Lets say we have:

/controllers/users/edit.php


First, notice how the namespace has changed. The path to the file has changed and our namespace reflects it. This profile() method is loaded at:

/users/edit/profile/1

Since the parameter is required, this wont load:

/users/edit/profile

Things can be buried even deeper. So what does this accomplish? Well we can load all these URLs without any routing and without confusing the framework:

/users/
/users/1
/users/profile/1
/users/edit/1
/users/edit/profile/1

This reduces unnecessary controller logic to determine what you want to load. Each function can be mapped to it's own controller method.

If you're this far and I haven't confused you, what do you think? (I'm also trying to think of ways that you could confuse it.)

-=-=-
Quit posting and try Google.
Mon, 16 Jan 2012, 03:27
JL235
I'd see this as a requirement, not a feature. 99% of MVC frameworks have this already.
Mon, 16 Jan 2012, 12:35
Stealth
Other frameworks use a baby version of this. For instance, index methods have to be remapped hide the method:

CodeIgniter FAQ:

How do I pass parameters to a controller's index() function?

The obvious problem is that a second parameter on the URL will be interpreted as the method name.

Short answer - use a URL like this: /controller/index/param1/param2

Long answer - using _remap() you can work some magic. This code is supplied courtesy of Colin Williams


This is also the case for other popular frameworks:

Kohana
CakePHP
Symfony

They do allow flexibility, but only through the use of routing overrides. Deeply nesting classes is also impractical because it requires far too much routing.

The idea behind nesting is simple. You have a controller and method:

/class/method

This allows you to map one general keyword (the class) to an infinite number of methods. Sometimes a single method does multiple things and it would be nice to map an infinite number of methods to another method. Thus, you can do:

/class/class/method

And so on:

/class/class/class/method


Do you see how this is different now?

-=-=-
Quit posting and try Google.
Mon, 16 Jan 2012, 12:50
JL235
Yeah, ok, I can see the difference. But it seems a little over engineered.

If I had a user profile and edit methods, I'd probably put them in the same controller, next to each other.

Easier to work on framework, and less navigating needed between folder and files. Having to navigate lots of files is a bad thing.
Mon, 16 Jan 2012, 13:10
Stealth
I'm curious if you prefer routing rules over this? I'm in the mindset that routing rules are an over engineered solution for a crappy router.

-=-=-
Quit posting and try Google.