Jump to content

RockDummyData


bernhard
 Share

Recommended Posts

Hi,

just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone.

https://gitlab.com/baumrock/RockDummyData/

easy example:

$rdd = $modules->get('RockDummyData');
for($i=0; $i<15; $i++) {
    // this has to be inside the for-loop to always get a new dummy
    $dummy = $rdd->getDummy();
    echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>";
}

more advanced:

$json = new stdClass();
$json->data = array();
$rdd = $modules->get('RockDummyData');
for($i=0; $i<3000; $i++) {
    // this has to be inside the for-loop to always get a new dummy
    $dummy = $rdd->getDummy();
    $obj = new stdClass();
    $obj->name = $dummy->forename . ' ' . $dummy->surname;
    $obj->position = $dummy->job;
    $obj->office = $dummy->city;
    $obj->color = $dummy->color;
    $obj->start_date = new stdClass();
        $obj->start_date->display = date('d.m.Y',$dummy->timestamp);
        $obj->start_date->sort = $dummy->timestamp;
    $obj->salary = rand(0,10000);
    $json->data[] = $obj;
}
echo json_encode($json);

you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module :)

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...