# Read N events from disk resident tree into memory

**URL:** <https://root-forum.cern.ch/t/read-n-events-from-disk-resident-tree-into-memory/4126>\
**Category:** ROOT\
**Created:** [November 24, 2006, 3:57pm UTC](https://root-forum.cern.ch/t/read-n-events-from-disk-resident-tree-into-memory/4126 "2006-11-24T15:57:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/dec6dc/32.png) [@joa](https://root-forum.cern.ch/u/joa)\
**Post date:** [November 24, 2006, 3:57pm UTC](https://root-forum.cern.ch/t/read-n-events-from-disk-resident-tree-into-memory/4126/1 "2006-11-24T15:57:38Z")

</div>

Hi,

I would like to benchmark a few different ways of doing the same thing, but without including disk IO in this. The idea is to read some fixed number N of events into the RAM, and then do what is supposed to be done with the events. I could of course allocate a bit of memory and read the entries from my tree and copy them into the allocated memory. My question is, can I have the TTree class to do this for me? Can I ask it to read in chunks of events into the memory (my events are not all of the same length) and can I then just loop over the events as ususal, at for each N events the tree will reload the memory with events and then read from memory and not the disk? I could then time the time for N events with disk IO, right?

cheers

Joa

---

<div class="post-metadata">

**Author:** ![brun](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/b9e5f3/32.png) [@brun](https://root-forum.cern.ch/u/brun)\
**Post date:** [November 24, 2006, 4:34pm UTC](https://root-forum.cern.ch/t/read-n-events-from-disk-resident-tree-into-memory/4126/2 "2006-11-24T16:34:32Z")

</div>

Make a memory-resident Tree with N events and save/read chunk from disk whenever you need it

Rene
