Expensive Logic in my Custom Blocks...maybe?

Permalink Browser Info Environment
Hello Jordan...

I've got everything working and displaying perfectly, so Thank You!

Now I've just got this problem with (no) speed. Pingdom tests show that it takes 20 to 30 seconds for the site to load...

I'm wondering if it's because the logic I'm putting in these Custom Blocks is Expensive?

According to the Speed Up C5 post...

Putting block startup logic in the block constructor (the __construct) method = BAD

Sticking your block startup logic in a method named "on_start" = GOOD.

I've looked for other posts on block-building, I've looked at other blocks...where and how do you make an "on_start" method? In the Designer Content package? In the custom block?

I attached a file of my view.php for Sports (there's a bit of logic testing here)...I don't enough of PHP to know if this logic and that of 3 other custom blocks might be grinding everything to a crawl...

I know yer busy with all your programming and buoying the morale of struggling users with your wealth of information, but when you are able, could you tell me where to begin?

Thanks again...

James

1 Attachment

Type: Discussion
Status: New
pkunzipula
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Hi James,
The only way to know for sure is to test things. Remove your custom blocks from a page and see how long it takes for that page to load. Is it just as long? Then that means the problem is not with the blocks. If it loads super fast, though, then it might be due to something in one of your blocks.

That being said, I can pretty much guarantee that no amount of code you put into a block like this is going to result in 30 second page loads -- so you should definitely do some testing as outlined above, but I'm guessing something else is going on here.

It can be quite tricky to diagnose these kinds of issues, so unfortunately I can't give you a silver bullet answer about this -- you'll have to do more research in the forums about what to look into. Also, it's very possible your web hosting is at fault here, because 20 to 30 seconds for a page is unbelievably long.

---

BTW, to answer your specific question -- did you put any startup logic (code) in the block constructor? I'm guessing "no" because the file you attached to show me your code is the view, not the controller. Regardless, unless you put in some really weird stuff there, it wouldn't cause a 30 second slowdown.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.