Jump to content

Search the Community

Showing results for tags 'performance'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 8 results

  1. Hi, I'm writing a script that scans images for numberplate edges in different angles. The below script works and picks up the edges in ~2 seconds. I'm curious if I can improve this to find the edges even faster. real 0m1.917s user 0m1.767s sys 0m0.125s <?php require __DIR__ . '/../vendor/autoload.php'; use Imagine\Image\Palette\Color\ColorInterface; use Imagine\Image\PointInterface; use Imagine\Image\ImageInterface; use Imagine\Image\Point; $topLeft = $bottomLeft = [99999, 0]; $topRight = $bottomRight = [0, 99999]; $gatherer = function (ColorInterface $color, PointInterface $point, ImageInterface $image) use (&$topLeft, &$topRight, &$bottomLeft, &$bottomRight) { if ($color->getAlpha() == 0) { return; } $x = $point->getX(); $y = $point->getY(); $top = $image->getColorAt(new Point($x, $y - 1))->isOpaque(); $bottom = $image->getColorAt(new Point($x, $y + 1))->isOpaque(); $left = $image->getColorAt(new Point($x - 1, $y))->isOpaque(); $right = $image->getColorAt(new Point($x + 1, $y))->isOpaque(); if (!$top && !$left && $bottom && $right && $x < $topLeft[0]) { $topLeft = [$x, $y]; } if (!$top && !$right && $bottom && $left && $x > $topRight[0]) { $topRight = [$x, $y]; } if (!$bottom && !$left && $top && $right && $x < $bottomLeft[0]) { $bottomLeft = [$x, $y]; } if (!$bottom && !$right && $top && $left && $x > $bottomRight[0]) { $bottomRight = [$x, $y]; } }; //$img = (new \Imagine\Gd\Imagine())->open(__DIR__ . '/numberplate-test.png'); $img = (new \Imagine\Gd\Imagine())->open(__DIR__ . '/numberplate-test2.png'); for ($top = 640; $top < 900; $top++) { for ($left = 340; $left < 1580; $left++) { $point = new Point($left, $top); $gatherer($img->getColorAt($point), $point, $img); } } var_dump($topLeft, $topRight, $bottomLeft, $bottomRight);
  2. So just to preface this, I have been part of two operations (one as developer, one with a 3rd party company developing) where the business was forced to cease due to difficulties in database load balancing and lots of people lost lots of money. I am talking about big data and high performance needed at the same time. So for my new project, I am going to try and design it around having a forever expanding infrastructure of servers but that means setting it correctly from the beginning. I have put together some ideas for possible ways to split the database load across multiple servers. Any input to which idea(s) are best would be great so I know which to explore further. Also any relevant info on this type of thing would be helpful as this is the first time I am personally doing this. Thanks!
  3. Here is the deal, its a simple script. 1-read a site link from a sql table**(sql1) 2-mark the sql1 line as read 3-goes to the site and capture several pieces of data(i used curl) 4-modify the read data 5-writes the data in another sql(sql2) So i did this with a few links, but i have to do this with 5~10 millions of links, what would be the better way to get performance and speed?
  4. This forum is "programming theory" so I assume this is the most appropriate place to put this. (Admins or someone feel free to move this if the location is incorrect.) The issue is that a site, example.com, loads slowly to international users because of its US-based host. So the thought is to buy... example.co.uk example.in example.br example.cn ... and host those domains on servers near the respective location. Or something like this. So the question is... what's the best way to handle users getting to the right site from the right location? There are google results out there that sort of address this question, but I'm wondering what has worked for others, or what you've heard of working. I think the solution will be to install a package on my server that can tell where the user is from, and to either redirect the user outright or to let them click a link to go to a more "local" version of the website. Thoughts? Have you handled this? Howso? Thanks
  5. I've set up a Download-Script with PHP on my server, which checks some details before letting the user download files via Apache (X-Sendfile). The Files are outside the Document-Root. The code for downloading with Apache and the Module X-Sendfile is: header("X-Sendfile: $fullpath"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$link_file\""); When using Apache and X-Sendfile i have a download-speed of 500 kB/s with my client. I also tested it with Apache and without X-Sendfile with the same file within the Document Root - same thing here! So I tested downloading the same file, with the same client, the same infrastructure on both sides and the same internet-connection a few seconds later via PHP with readfile: header("Pragma: no-cache"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Content-Length: ".(string)(filesize($fullpath))); header("Content-Disposition: attachment; filename=\"$link_file\""); readfile($fullpath); This time the download-speed was 9.500 kB/s! I repeated this test using both options more than a multiple times and the result was the same every time trying. The only difference besides the download-speed was a waiting time of a few seconds (depending on the size of the file which was downloaded), when trying with the PHP readfile method. When repeating the PHP readfile method instantly, the waiting time didn't appear again. Most likely because it was stored in the memory after the first time. I'm using a professional HP Raid-System on the server, which has an average local Speed of 800 MB/s, so the reason for this can't be the Diskspeed. Also i didn't find any compressing- or bandwith-settings in the httpd.conf of Apache. Can anyone of you explain why there is such a great difference of the download-speed and how this can be changed? Thank you in advance. Server: Windows Server 2008 R2 Apache/2.2.21 (Win32) PHP/5.4.20 Client: Windows 7 Ultimate x64 Google Chrome 30.0.1599.101 LAN >100 Mbit/s
  6. I'm working on a site with a large category database > 3000 categories. I have successfully loaded my category list into phpmyadmin (tables in Myisam). However when attempting to load the site (localhost), the site times out. The site times out after 30seconds and gets stuck on a subcategory count in php. Here's the line of code it gets stuck at while loading: function GetSubCatCount($catid){ global $db, $the_cats; $count = 0; foreach($the_cats as $cat){ if(isset($cat->category_parent)){ if($cat->category_parent == $catid && $cat->category__auto_id <> 0 && $cat->category_lang == $dblang) { $count = $count + 1; } } } return $count; } This counting method seems rather slow. How can I speed up the count of the subcategories in php or have Mysql send the subcategory count values? Thanks and Regards! Database: pligg Table: pligg_categories Table details: |category__auto_id |category_lang |category_id |category_parent |category_name |category_safe_name |rgt |lft |category_enabled |category_order |category_desc |category_keywords |category_author_level |category_author_group |category_votes |category_karma Software version: 5.5.25a - MySQL Community Server (GPL)
  7. A little background on the project I'm working on: I have a reasonably large number of values, over 500k rows worth. The values are generated per hour, per parent. I want to group these values by one of four time intervals: Month, week, day or hour, and get the average for this period. The challenge comes by the fact that I need to split the values into two different blocks, based upon whether the value was generated during the "day" or "night/weekend". So far I've come up with two different approaches to this: Have two fields in the table for saving the values, one for the "daytime" values and the other for "night time/weekend" values. This would allow me to run separate functions on the fields, without involving the date functions in MySQL. At the cost of having two fields for what is essentially the same type of data, and having to do the splitting in the pre-insert phase. Save all values in the same field, and then use MySQL's datetime functions with a CASE-WHEN to figure out in which block they belong. This approach seems to be the cleanest one in terms of database-design, but I fear it will put a lot of strain on the database. Especially since the SELECT statements will run more often than the insertion script. So the question is if I should go for the first approach, the second, or if there is some other solution to this that I've failed to grasp? I could really do with some expert help on this one. Example values: Desired output:
  8. Hey all I am a self-taught AS3/Flex/AIR developer and I have built a system of touchscreen-kiosks running on AIR with remote content managment from an online Flex app. This is the first time I have done server side stuff, so feel free to correct my question if needed. Both the AIR apps and the Flex app connect to a mysql database for simple CRUD operations using php scripts and the Zend framework. The kiosks call the server every 30 seconds to update. All these simple server side php scripts were auto-generated by Flash Builder's data wizard. I did the simple adjusments (gateway.php, config.ini, mysqli connection parameters) and deployed everything to the client's server. This is a a shared-server type. Now, the system works. But it works slowly. Each create/read/update/delete operation works but I think it should be a lot faster. Also, these operations put a lot of load on the server's cpu. According to the hosting guys, this system opens 6 php-cgi proccesses that take up 40% of the server cpu power, and by doing so slows itself down and other sites hosted on that server. My questions are: First of all, is there a problem to begin with or is this performance expexted from the Zend framework? Are the auto-generated scripts written by Flash Builder poorly written and can be optimized? Can this kind of system stay on a shared-hosted-server? Should we move to a VPS server for better performance? Is it posiible that if the tables I created on the mysql database with phpmyadmin weren't optimiatlly built that it would have this kind of impact on performance? I don't know php or mysql. Any kind of help will be much appriciated. Saar Here is the script written by Flash Builder: I havn't added anything - just changed the connection parameters. <?php class KiosksService { var $username = "--------"; var $password = "--------"; var $server = "--------"; var $port = "3306"; var $databasename = "--------"; var $tablename = "kiosks"; var $connection; /** * The constructor initializes the connection to database. Everytime a request is * received by Zend AMF, an instance of the service class is created and then the * requested method is invoked. */ public function __construct() { $this->connection = mysqli_connect( $this->server, $this->username, $this->password, $this->databasename, $this->port ); $this->throwExceptiononerror($this->connection); } /** * Returns all the rows from the table. * * Add authroization or any logical checks for secure access to your data * * @return array */ public function getAllKiosks() { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename"); $this->throwExceptiononerror(); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); $rows = array(); mysqli_stmt_bind_result($stmt, $row->KioskID, $row->Station, $row->Branch, $row->Chain, $row->Pingdate, $row->Layout, $row->Online, $row->Clips, $row->Extra); while (mysqli_stmt_fetch($stmt)) { $row->Pingdate = new DateTime($row->Pingdate); $rows[] = $row; $row = new stdClass(); mysqli_stmt_bind_result($stmt, $row->KioskID, $row->Station, $row->Branch, $row->Chain, $row->Pingdate, $row->Layout, $row->Online, $row->Clips, $row->Extra); } mysqli_stmt_free_result($stmt); mysqli_close($this->connection); return $rows; } /** * Returns the item corresponding to the value specified for the primary key. * * Add authorization or any logical checks for secure access to your data * * * @return stdClass */ public function getKiosksByID($itemID) { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where KioskID=?"); $this->throwExceptiononerror(); mysqli_stmt_bind_param($stmt, 'i', $itemID); $this->throwExceptiononerror(); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); mysqli_stmt_bind_result($stmt, $row->KioskID, $row->Station, $row->Branch, $row->Chain, $row->Pingdate, $row->Layout, $row->Online, $row->Clips, $row->Extra); if(mysqli_stmt_fetch($stmt)) { $row->Pingdate = new DateTime($row->Pingdate); return $row; } else { return null; } } /** * Returns the item corresponding to the value specified for the primary key. * * Add authorization or any logical checks for secure access to your data * * * @return stdClass */ public function createKiosks($item) { $stmt = mysqli_prepare($this->connection, "INSERT INTO $this->tablename (Station, Branch, Chain, Pingdate, Layout, Online, Clips, Extra) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $this->throwExceptiononerror(); mysqli_stmt_bind_param($stmt, 'sssssisi', $item->Station, $item->Branch, $item->Chain, $item->Pingdate->toString('YYYY-MM-dd HH:mm:ss'), $item->Layout, $item->Online, $item->Clips, $item->Extra); $this->throwExceptiononerror(); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); $autoid = mysqli_stmt_insert_id($stmt); mysqli_stmt_free_result($stmt); mysqli_close($this->connection); return $autoid; } /** * Updates the passed item in the table. * * Add authorization or any logical checks for secure access to your data * * @param stdClass $item * @return void */ public function updateKiosks($item) { $stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET Station=?, Branch=?, Chain=?, Pingdate=?, Layout=?, Online=?, Clips=?, Extra=? WHERE KioskID=?"); $this->throwExceptiononerror(); mysqli_stmt_bind_param($stmt, 'sssssisii', $item->Station, $item->Branch, $item->Chain, $item->Pingdate->toString('YYYY-MM-dd HH:mm:ss'), $item->Layout, $item->Online, $item->Clips, $item->Extra, $item->KioskID); $this->throwExceptiononerror(); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); mysqli_stmt_free_result($stmt); mysqli_close($this->connection); } /** * Deletes the item corresponding to the passed primary key value from * the table. * * Add authorization or any logical checks for secure access to your data * * * @return void */ public function deleteKiosks($itemID) { $stmt = mysqli_prepare($this->connection, "DELETE FROM $this->tablename WHERE KioskID = ?"); $this->throwExceptiononerror(); mysqli_stmt_bind_param($stmt, 'i', $itemID); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); mysqli_stmt_free_result($stmt); mysqli_close($this->connection); } /** * Returns the number of rows in the table. * * Add authorization or any logical checks for secure access to your data * * */ public function count() { $stmt = mysqli_prepare($this->connection, "SELECT COUNT(*) AS COUNT FROM $this->tablename"); $this->throwExceptiononerror(); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); mysqli_stmt_bind_result($stmt, $rec_count); $this->throwExceptiononerror(); mysqli_stmt_fetch($stmt); $this->throwExceptiononerror(); mysqli_stmt_free_result($stmt); mysqli_close($this->connection); return $rec_count; } /** * Returns $numItems rows starting from the $startIndex row from the * table. * * Add authorization or any logical checks for secure access to your data * * * * @return array */ public function getKiosks_paged($startIndex, $numItems) { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename LIMIT ?, ?"); $this->throwExceptiononerror(); mysqli_stmt_bind_param($stmt, 'ii', $startIndex, $numItems); mysqli_stmt_execute($stmt); $this->throwExceptiononerror(); $rows = array(); mysqli_stmt_bind_result($stmt, $row->KioskID, $row->Station, $row->Branch, $row->Chain, $row->Pingdate, $row->Layout, $row->Online, $row->Clips, $row->Extra); while (mysqli_stmt_fetch($stmt)) { $row->Pingdate = new DateTime($row->Pingdate); $rows[] = $row; $row = new stdClass(); mysqli_stmt_bind_result($stmt, $row->KioskID, $row->Station, $row->Branch, $row->Chain, $row->Pingdate, $row->Layout, $row->Online, $row->Clips, $row->Extra); } mysqli_stmt_free_result($stmt); mysqli_close($this->connection); return $rows; } /** * Utility function to throw an exception if an error occurs * while running a mysql command. */ private function throwExceptiononerror($link = null) { if($link == null) { $link = $this->connection; } if(mysqli_error($link)) { $msg = mysqli_errno($link) . ": " . mysqli_error($link); throw new Exception('MySQL Error - '. $msg); } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.