I make a stress test of the SQL Server 2008 and I want to know what is the data flow to tempdb because of usage of temporary tables and variables.
The statistics is also shown in Activity Monitor:

Is it possible somehow to record the data and afterwards analyse it?
I have 2 cases in mind:
- Record an SQL Server counter (I don’t know which is the name for it)
- Record somehow data from Activity Monitor
Writing into a database does not equate 1 to 1 with disk IO. Database updates only dirty in-memory pages that are later copied to disk by the lazy writer or at checkpoint. The only thing written to disk is the Write Ahead Log activity, for which there is a specific per database counter: Log Bytes Flushed/sec. Note that
tempdbhas special logging requirements as it is never recovered so it only needs undo information. Whenever dirty pages are actually flushed, be it at checkpoint or by lazy writer, there are specific counters for that too: Checkpoint pages/sec and Lazy writes/sec. These are not per database because these activities themselves are not ‘per database’. Finally there are the virtual file stats DMVs:sys.dm_io_virtual_file_statswhich offer the aggregate number of IO operations and number of bytes for each individual file of each individual database, including tempdb.You mention that you want to measure the specific impact of temp tables and table variables, but you won’t be able to separate them from the rest of tempdb activities (sort spools, worktables etc). I recommend you go over Working with tempdb in SQL Server 2005, as it still applies to SQL 2008.