mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
* Add CGFloat, CGPoint, CGSize, CGRect * Add WindowCollectionBehavior, WindowLevel, and WindowTabbingMode * Change EventMask to ulong to match the objc unsigned long long * Change int types to NS(U)Integer types to match objc * Add core foundation tests * Add objc tests * Add darwin conditional to the test files * Change enums to const inline to better match the NSEvent.h api. Update the EventMask helper function to match the NSEvent.h api: event_type_from -> event_mask_from_type. * Update the release notes * Deprecate original objc enums and replace with const inline enums backed with NS numerical types. Rename the new objc enums with an NS prefix. Update unit tests to account for new NS prefixed enums. Add states item length constants to core_foundation. Status item lengths don't really belong in either file, but as they are dependant on CGFloat it made sense to move them to the same module. Update release notes. * Some tweaks --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
65 lines
1010 B
C
65 lines
1010 B
C
// Copyright (c) 2019 Christoffer Lerno. All rights reserved.
|
|
// Use of this source code is governed by the GNU LGPLv3.0 license
|
|
// a copy of which can be found in the LICENSE file.
|
|
|
|
#include "utils/common.h"
|
|
#include "benchmark.h"
|
|
#include <time.h>
|
|
|
|
BenchTime begin;
|
|
|
|
#if USE_PTHREAD
|
|
|
|
|
|
void bench_begin(void)
|
|
{
|
|
clock_gettime(CLOCK_MONOTONIC, &begin);
|
|
}
|
|
|
|
|
|
double bench_mark(void)
|
|
{
|
|
return benchmark(begin);
|
|
}
|
|
|
|
BenchTime benchstart(void)
|
|
{
|
|
BenchTime res;
|
|
clock_gettime(CLOCK_MONOTONIC, &res);
|
|
return res;
|
|
}
|
|
|
|
double benchmark(BenchTime start)
|
|
{
|
|
BenchTime res;
|
|
clock_gettime(CLOCK_MONOTONIC, &res);
|
|
double elapsed = (res.tv_sec - start.tv_sec);
|
|
elapsed += (res.tv_nsec - start.tv_nsec) / 1000000000.0;
|
|
return elapsed;
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
void bench_begin(void)
|
|
{
|
|
begin = clock();
|
|
}
|
|
double bench_mark(void)
|
|
{
|
|
return (clock() - begin) / (double)CLOCKS_PER_SEC;
|
|
}
|
|
|
|
BenchTime benchstart(void)
|
|
{
|
|
return clock();
|
|
}
|
|
|
|
double benchmark(BenchTime start)
|
|
{
|
|
return (clock() - start) / (double)CLOCKS_PER_SEC;
|
|
}
|
|
|
|
#endif
|
|
|