none
How to get the total net proccess time (of all the cores) for a specific job using C# API RRS feed

  • Question

  • In my application I need to get the total net proccess time (of all the cores that run the job) for a specific job that the user chooses.

    how can i get it using C#?

    Thanks ,

    Ben

    Monday, October 24, 2011 11:37 AM

Answers

  • Here is a quick fragment that will fetch the total cpu time for a given JobId:

                using (IScheduler scheduler = new Scheduler())
                {
                    scheduler.Connect("localhost");

                    int desiredJobId = 3;
                    IFilterCollection filter = scheduler.CreateFilterCollection();

                    filter.Add(new FilterProperty(FilterOperator.Equal, JobPropertyIds.Id, desiredJobId));

                    ISchedulerCollection jobs = scheduler.GetJobList(filter, null /* no sort order specified */);
                    ISchedulerJob job = jobs[0] as ISchedulerJob;
                    ISchedulerJobCounters counters = job.GetCounters();

                    long totalCpuTime = counters.TotalCpuTime;
                }

    • Proposed as answer by DarylMsft Tuesday, November 1, 2011 11:46 PM
    • Marked as answer by Ben.Alterzon Thursday, November 3, 2011 12:48 PM
    Tuesday, November 1, 2011 11:45 PM

All replies

  • ISchedulerJobCounters.TotalCpuTime Property might be what you are looking for (http://msdn.microsoft.com/en-us/library/microsoft.hpc.scheduler.ischedulerjobcounters.totalcputime(VS.85).aspx).
    daryl
    Thursday, October 27, 2011 10:05 PM
  • Hi Daryl,

    I would appreciate if I can get an example.

    Thanks,

    Ben

    Sunday, October 30, 2011 2:27 PM
  • Here is a quick fragment that will fetch the total cpu time for a given JobId:

                using (IScheduler scheduler = new Scheduler())
                {
                    scheduler.Connect("localhost");

                    int desiredJobId = 3;
                    IFilterCollection filter = scheduler.CreateFilterCollection();

                    filter.Add(new FilterProperty(FilterOperator.Equal, JobPropertyIds.Id, desiredJobId));

                    ISchedulerCollection jobs = scheduler.GetJobList(filter, null /* no sort order specified */);
                    ISchedulerJob job = jobs[0] as ISchedulerJob;
                    ISchedulerJobCounters counters = job.GetCounters();

                    long totalCpuTime = counters.TotalCpuTime;
                }

    • Proposed as answer by DarylMsft Tuesday, November 1, 2011 11:46 PM
    • Marked as answer by Ben.Alterzon Thursday, November 3, 2011 12:48 PM
    Tuesday, November 1, 2011 11:45 PM